Closed alishanamin closed 11 months 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".
Closing due to no response.
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
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) }
}