pusher / push-notifications-flutter

Official Pusher Beams Flutter client plugin (iOS, Android and Web), receive notifications easily on your Flutter application with Pusher Beams.
https://pub.dev/packages/pusher_beams
MIT License
10 stars 27 forks source link

IOS Not receiving notifications? #42

Closed alishanamin closed 11 months ago

alishanamin commented 1 year ago

import UIKit import Flutter import GoogleMaps import PushNotifications

@UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { let pushNotifications = PushNotifications.shared override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GMSServices.provideAPIKey("AIzaSyBARUcZj5RgVXtIx2m0wSsjN5SkVJWK8_c") GeneratedPluginRegistrant.register(with: self) self.pushNotifications.start(instanceId: "30a81320-cc4c-4453-97c6-154fcf1d1ae8") self.pushNotifications.registerForRemoteNotifications() try? self.pushNotifications.addDeviceInterest(interest: "BogoCanada") return super.application(application, didFinishLaunchingWithOptions: launchOptions) }

override func application( application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { self.pushNotifications.registerDeviceToken(deviceToken) } override func application( application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { print(userInfo) }

}

benjamin-tang-pusher commented 1 year ago

When you call the start() method whilst your iphone is connected to your XCode, the library will print out its logging to your terminal. Do you see any output? It its working correctly, it should say something like "successfully registered for notifications".

benjamin-tang-pusher commented 11 months ago

Closing due to no response.

atoruliahotshotslabs commented 2 weeks ago

Hello, I encountered a similar error. For testing, I connected a real device through debug mode to Xcode. As a result, I saw the following logs:

[PushNotifications]: Network error: Error: Device could not be created
[PushNotifications]: Network error: Error: Device could not be created
[PushNotifications]: Network error: Error: Device could not be created
[PushNotifications]: Network error: Error: Device could not be created
[PushNotifications]: Network error: Error: Device could not be created
[PushNotifications]: Network error: Error: Device could not be created
[PushNotifications]: Network error: Error: Device could not be created
[PushNotifications] - It looks like setUserId hasn't completed yet -- have you called `registerDeviceToken`?
[PushNotifications]: Network error: Error: Device could not be created

I call the start() method as soon as possible in the main method. Also, I call setUserId every time there is a request to obtain an authorization token