Open nianshaofanghua opened 3 years ago
我是修改了iOS代码,增加didRegisterForRemoteNotificationsWithDeviceToken方法,在这个方法中获取deviceToken,将值写入userdefault。
放AppDelegate.swift里
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let deviceTokenStr = [UInt8](deviceToken).map{String(format: "%02x", $0)}.joined()
NSLog("deviceToken:--------> " + deviceTokenStr)
UserDefaults.standard.set(deviceTokenStr, forKey: "push_device_token")
}
/// get DeviceToken [DeviceToken] static Future<String?> deviceToken() async { Map<String, dynamic> args = {}; return _methodChannel.invokeMethod('deviceToken', args); }