pushy / pushy-flutter

The official Pushy SDK for Flutter apps.
Apache License 2.0
21 stars 19 forks source link

Pushy.register() hangs when called #38

Closed toladele closed 2 years ago

toladele commented 2 years ago

Similar to this issue: https://github.com/pushy-me/pushy-flutter/issues/20

Pushy.register() doesn't return a device token when called, instead it hangs and no line after it is executed. I followed the steps in the documentation. Currently on Pushy version 2.0.4. I use Firebase in my app, however currently migrating from FCM to Pushy and I've removed all FCM plugins.


try {
      // Register the user for push notifications
      String deviceToken = await Pushy.register();

      // Print token to console/logcat
      print('Device token: $deviceToken');
pushy commented 2 years ago

Hi @toladele, We'd be glad to assist.

If the Pushy.register() callback isn't invoked in your iOS app, please ensure your project isn't using any other push notification library, such as Firebase Cloud Messaging, Firebase Auth, APNs, OneSignal, React Native Push Notification, etc.

These libraries clash with the Pushy iOS SDK as they hook into (swizzle) the APNs methods which the Pushy iOS SDK relies on.

Also, please make sure your AppDelegate class does not override any of the following APNs methods:

application:didRegisterForRemoteNotificationsWithDeviceToken
application:didFailToRegisterForRemoteNotificationsWithError
application:didReceiveRemoteNotification:fetchCompletionHandler

If you'd like to use multiple push libraries at the same time, please see this article to disable swizzling in the Pushy iOS SDK while invoking our internal methods manually in each AppDelegate APNs callback.

iOS 13: Due to a bug in iOS 13, the pushy.register() callback may never be called when your device is connected through Wi-Fi in rare scenarios. The only solution appears to be to temporarily connect to a different Wi-Fi network, or connecting through cellular instead. This bug was fixed by Apple in future versions of iOS.

toladele commented 2 years ago

Thanks for your quick response. The article you linked was the solution!