Showing
1 changed file
with
9 additions
and
2 deletions
@@ -17,8 +17,15 @@ public class FlutterPushPlugin: NSObject, FlutterPlugin { | @@ -17,8 +17,15 @@ public class FlutterPushPlugin: NSObject, FlutterPlugin { | ||
17 | case "init": | 17 | case "init": |
18 | print("init初始化") | 18 | print("init初始化") |
19 | // 初始化 | 19 | // 初始化 |
20 | - DispatchQueue.main.async { | ||
21 | - UIApplication.shared.registerForRemoteNotifications() | 20 | + UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in |
21 | + if granted { | ||
22 | + print("有通知权限") | ||
23 | + DispatchQueue.main.async { | ||
24 | + UIApplication.shared.registerForRemoteNotifications() | ||
25 | + } | ||
26 | + } else { | ||
27 | + print("无用通知权限") | ||
28 | + } | ||
22 | } | 29 | } |
23 | result(true) | 30 | result(true) |
24 | case "checkPermission": | 31 | case "checkPermission": |
-
Please register or login to post a comment