registerDeviceToken method

Future<void> registerDeviceToken(
  1. String token
)

Re-register the device token. Mirrors Android AegisPushTracker.reRegisterToken + iOS AegisPushTracker.shared.registerDeviceToken.

Implementation

Future<void> registerDeviceToken(String token) async {
  if (_writeKey == null) {
    if (kDebugMode) {
      // ignore: avoid_print
      print('[Active Reach Push] registerDeviceToken: SDK not configured');
    }
    return;
  }
  final body = <String, dynamic>{
    'device_token': token,
    'platform': defaultTargetPlatform == TargetPlatform.iOS ? 'ios' : 'android',
    if (_propertyId != null) 'property_id': _propertyId,
    if (_contactId != null) 'contact_id': _contactId,
    if (_anonymousId != null) 'anonymous_id': _anonymousId,
    'user_agent': 'ActiveReach-Flutter-SDK/0.3.0',
  };
  await _post('/v1/devices/register', body);
}