drybnikov / klaviyo_flutter

BSD 3-Clause "New" or "Revised" License
4 stars 9 forks source link

Not Receiving Notifications In IOS/Android #7

Open abubakarflutter opened 10 months ago

abubakarflutter commented 10 months ago

i am unable to get push notification in my IOS real device in using Klaviyo i don't know why i am getting the following error that "handleBackgroundMessage" can't be found, moreover, where to listen the notification and how to show that. no proper steps has been defined. Please help

Screenshot of a code

drybnikov commented 10 months ago

Hello, try adding this code to firebaseMessagingBackgroundHandler:

    final data = message.data;
    final klaviyo = Klaviyo.instance;

    if (klaviyo.isKlaviyoPush(data)) {
      if (!klaviyo.isInitialized) {
        await klaviyo.initialize(KLAVIYO_TOKEN);
      }
      final result = await klaviyo.handlePush(data);
    }
abubakarflutter commented 10 months ago

Hello, try adding this code to firebaseMessagingBackgroundHandler:

    final data = message.data;
    final klaviyo = Klaviyo.instance;

    if (klaviyo.isKlaviyoPush(data)) {
      if (!klaviyo.isInitialized) {
        await klaviyo.initialize(KLAVIYO_TOKEN);
      }
      final result = await klaviyo.handlePush(data);
    }

klaviyo.initialize will have the API KEY not the klaviyo token, token is something that is related to FCM or APN

Additionally, where to listen the notification and trigger the local_push_notification function to actually show the notification in the mobile app? I am unable to get it, like where we are listening the klaviyo notifications?

moreover the method >handlePush will only return bool , how this will trigger the show notification function?

abubakarflutter commented 10 months ago

Any update

Hello, try adding this code to firebaseMessagingBackgroundHandler:

    final data = message.data;
    final klaviyo = Klaviyo.instance;

    if (klaviyo.isKlaviyoPush(data)) {
      if (!klaviyo.isInitialized) {
        await klaviyo.initialize(KLAVIYO_TOKEN);
      }
      final result = await klaviyo.handlePush(data);
    }

Any thoughts? waiting for your answer