Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios push notifications not recieved to Flutter #1

Closed
Korpyc opened this issue May 25, 2023 · 5 comments
Closed

ios push notifications not recieved to Flutter #1

Korpyc opened this issue May 25, 2023 · 5 comments

Comments

@Korpyc
Copy link
Contributor

Korpyc commented May 25, 2023

Hey, I've installed your package, I has Firebase messaging which correctly work with my backend server. But, Klaviyo notifications are not received by Flutter code.

Are you sure that your app getting Klaviyo notifications data inside Flutter code???

The hack, that I've used for handling deeplinks, it's I've added handling on iOS side, like code below. The only problem that I've noticed, app receiving it twice.


import UIKit
import Flutter
import Firebase
import KlaviyoSwift

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
      GeneratedPluginRegistrant.register(with: self)
      if #available(iOS 10.0, *) {
                UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
    }
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
    
}


// deeplink handle
extension AppDelegate {
       override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
          KlaviyoSDK().handle(notificationResponse: response, withCompletionHandler: completionHandler)
        }
    }
@drybnikov
Copy link
Owner

Thank you for your input, I added this userNotificationCenter function as a delegate in the Flutter plugin and now push tracking and deep-linking on iOS should send to Flutter and work.
Could you please try the latest update 0.0.1+5 and back with the results?

@Korpyc
Copy link
Contributor Author

Korpyc commented May 26, 2023

I've tried, changes work's for me as well. Deeplink was handled. But overall, can't read notification inside the Flutter code, as it's not received by Firebase messaging instance.

@drybnikov
Copy link
Owner

Did you subscribing to FirebaseMessaging listeners?

FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) => _onBackgroundPushOpenedApp(message));
FirebaseMessaging.onMessage.listen((RemoteMessage message) => _onForegroundPushDisplayed(message));

Or check if the push was received while the app terminated?

RemoteMessage? remoteMessage = await FirebaseMessaging.instance.getInitialMessage();

This RemoteMessage object usually contains a deeplink: message.data['url']

Also nice to have are top level function marked as an entry point for iOS app
https://pub.dev/packages/flutter_local_notifications#-usage

Future firebaseMessagingBackgroundHandler(RemoteMessage message) async

@Korpyc
Copy link
Contributor Author

Korpyc commented May 26, 2023

Yes, those listeners are written and work correctly, because my app successfully receive notifications from backend server & test notifications from Firebase console.

@waynepollen
Copy link

This shouldn't have been closed IMO - the last message from @drybnikov only confirmed that the firebase side is working. I am able to send from firebase and the handlers are called however if i send from Klaviyo they are not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants