initialize method

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

Initialize ParsePush; for web a vapidKey is required.

Implementation

Future<void> initialize(
  firebaseMessaging, {
  String? vapidKey,
  required ParseNotification parseNotification,
}) async {
  _parseNotification = parseNotification;

  // 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();
  });
}