subscribe static method

Future<void> subscribe({
  1. required String appToken,
  2. required GlobalKey<NavigatorState> navigatorKey,
  3. String friendlyIdentifier = '',
  4. String? attributionId,
  5. String? phoneNumber,
  6. String? email,
  7. bool blockDeepLink = false,
  8. Function? firebaseListenCallback,
  9. Map<String, dynamic>? customFields,
  10. InngageWebViewProperties? inngageWebViewProperties,
  11. bool requestAdvertiserId = false,
  12. bool requestGeoLocator = false,
})

Implementation

static Future<void> subscribe({
  required String appToken,
  required GlobalKey<NavigatorState> navigatorKey,
  String friendlyIdentifier = '',
  String? attributionId,
  String? phoneNumber,
  String? email,
  bool blockDeepLink = false,
  Function? firebaseListenCallback,
  Map<String, dynamic>? customFields,
  InngageWebViewProperties? inngageWebViewProperties,
  bool requestAdvertiserId = false,
  bool requestGeoLocator = false,
}) async {
  try {
    //initialize firebase
    defaultApp = await Firebase.initializeApp();
    if (requestGeoLocator) {
      var result = await GeoLocal.handlePermission();
      InngageProperties.latitude = result.latitude.toString();
      InngageProperties.longitude = result.longitude.toString();
    }
  } catch (error) {
    if (InngageProperties.getDebugMode()) {
      debugPrint(error.toString());
    }
  }
  InngageUtils.requestAdvertiserId = requestAdvertiserId;

  //validation identifier
  if (friendlyIdentifier.isEmpty) {
    InngageProperties.identifier = await InngageUtils.getId();
  } else {
    InngageProperties.identifier = friendlyIdentifier;
  }
  InngageProperties.appToken = appToken;
  InngageProperties.blockDeepLink = blockDeepLink;
  //set navigator key
  InngageProperties.navigatorKey = navigatorKey = navigatorKey;

  //set inngage web view properties
  if (inngageWebViewProperties != null) {
    InngageProperties.inngageWebViewProperties = inngageWebViewProperties;
  }
  //set inngage web view properties
  if (phoneNumber != null) {
    InngageProperties.phoneNumber = phoneNumber;
  }
  if (email != null) {
    InngageProperties.email = email;
  }

  //set customFields properties
  if (customFields != null) {
    InngageProperties.customFields = customFields;
  }
  if (firebaseListenCallback != null) {
    InngageNotificationMessage.firebaseListenCallback =
        firebaseListenCallback as void Function(dynamic r);
  }

  if (attributionId != null) {
    InngageProperties.attributionId = attributionId;
  }
}