11iOS如何绑定deviceToken?
22
3- ``` objectivec
3+ OC
44
5+ ``` objectivec
56#import " AppDelegate.h"
67// 引入环信SDK
78#import < Hyphenate/Hyphenate.h>
@@ -14,11 +15,11 @@ iOS如何绑定deviceToken?
1415
1516
1617- (BOOL)application:(UIApplication * )application didFinishLaunchingWithOptions:(NSDictionary * )launchOptions {
17-
18-
18+
19+
1920 // ...
20-
21-
21+
22+
2223 // // 获取UNUserNotificationCenter并申请[badge, alert, sound]权限。
2324 UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
2425 [center requestAuthorizationWithOptions:
@@ -31,8 +32,8 @@ iOS如何绑定deviceToken?
3132 });
3233 }
3334 }];
34-
35-
35+
36+
3637 return YES;
3738}
3839
@@ -45,11 +46,11 @@ iOS如何绑定deviceToken?
4546
4647
4748@end
48-
4949```
5050
51- ```swift
51+ Swift
5252
53+ ```swift
5354import UIKit
5455import Flutter
5556// 引入环信SDK
@@ -62,7 +63,7 @@ import HyphenateChat
6263 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
6364 ) -> Bool {
6465 GeneratedPluginRegistrant.register(with: self);
65-
66+
6667 // 获取UNUserNotificationCenter并申请[badge, alert, sound]权限。
6768 let center = UNUserNotificationCenter.current();
6869 center.requestAuthorization(options: [.badge, .alert, .sound]) { granted, error in
@@ -73,7 +74,7 @@ import HyphenateChat
7374 }
7475 }
7576 }
76-
77+
7778 return super.application(application, didFinishLaunchingWithOptions: launchOptions)
7879 }
7980 // 收到系统deviceToken获取成功回调
@@ -82,8 +83,4 @@ import HyphenateChat
8283 EMClient.share.registerForRemoteNotifications(withDeviceToken: deviceToken, completion: nil)
8384 }
8485}
85-
86-
87-
88-
8986```
0 commit comments