initialize method

Future<void> initialize(
  1. dynamic firebaseMessaging,
  2. {String? vapidKey}
)

Initialize ParsePush; for web a vapidKey is required.

Implementation

Future<void> initialize(
  firebaseMessaging, {
  String? vapidKey,
}) async {
  // Get Google Cloud Messaging (GCM) token
  firebaseMessaging
      .getToken(vapidKey: vapidKey)
      .asStream()
      .listen((event) async {
    // Set token in installation
    sdk.ParseInstallation parseInstallation =
        await sdk.ParseInstallation.currentInstallation();

    parseInstallation.deviceToken = event;
    parseInstallation.set(keyPushType, keyType);

    await parseInstallation.save();
  });
}