Skip to content

Commit cb03687

Browse files
committed
update QA file
1 parent 6c95aee commit cb03687

File tree

7 files changed

+123
-19
lines changed

7 files changed

+123
-19
lines changed

FlutterQA.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
iOS如何绑定deviceToken?
2+
3+
```objectivec
4+
5+
#import "AppDelegate.h"
6+
// 引入环信SDK
7+
#import <Hyphenate/Hyphenate.h>
8+
9+
@interface AppDelegate ()
10+
11+
@end
12+
13+
@implementation AppDelegate
14+
15+
16+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
17+
18+
19+
// ...
20+
21+
22+
// // 获取UNUserNotificationCenter并申请[badge, alert, sound]权限。
23+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
24+
[center requestAuthorizationWithOptions:
25+
UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound
26+
completionHandler:^(BOOL granted, NSError * _Nullable error) {
27+
if (granted) {
28+
dispatch_async(dispatch_get_main_queue(), ^{
29+
// 注册远程推送
30+
[application registerForRemoteNotifications];
31+
});
32+
}
33+
}];
34+
35+
36+
return YES;
37+
}
38+
39+
// 收到系统deviceToken获取成功回调
40+
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
41+
// 将deviceToken传给环信SDK
42+
[EMClient.sharedClient registerForRemoteNotificationsWithDeviceToken:deviceToken completion:nil];
43+
}
44+
45+
46+
47+
@end
48+
49+
```
50+
51+
```swift
52+
53+
import UIKit
54+
import Flutter
55+
// 引入环信SDK
56+
import HyphenateChat
57+
58+
@UIApplicationMain
59+
@objc class AppDelegate: FlutterAppDelegate {
60+
override func application(
61+
_ application: UIApplication,
62+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
63+
) -> Bool {
64+
GeneratedPluginRegistrant.register(with: self);
65+
66+
// 获取UNUserNotificationCenter并申请[badge, alert, sound]权限。
67+
let center = UNUserNotificationCenter.current();
68+
center.requestAuthorization(options: [.badge, .alert, .sound]) { granted, error in
69+
if(granted){
70+
DispatchQueue.main.async {
71+
// 注册远程推送
72+
application.registerForRemoteNotifications();
73+
}
74+
}
75+
}
76+
77+
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
78+
}
79+
// 收到系统deviceToken获取成功回调
80+
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
81+
// 将deviceToken传给环信SDK
82+
EMClient.share.registerForRemoteNotifications(withDeviceToken: deviceToken, completion: nil)
83+
}
84+
}
85+
86+
87+
88+
89+
```

README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
源码地址: [Github](https://github.com/easemob/im_flutter_sdk)
1212
任何问题可以通过 [Github Issues](https://github.com/easemob/im_flutter_sdk/issues) 提问
1313

14-
14+
[常见问题](FlutterQA.md)
1515

1616
## 前期准备
1717

@@ -159,8 +159,6 @@ class _PageState extends State<Page> implements EMConnectionListener {
159159
bool isConnected = await EMClient.getInstance.isConnected();
160160
```
161161

162-
163-
164162
### EMChatManager
165163

166164
#### 获取会话列表
@@ -480,27 +478,27 @@ class _PageState extends State<Page> implements EMContactManagerListener {
480478
481479
@override
482480
void onContactAdded(String userName) {
483-
481+
484482
}
485483
486484
@override
487485
void onContactDeleted(String? userName) {
488-
486+
489487
}
490488
491489
@override
492490
void onContactInvited(String userName, String? reason) {
493-
491+
494492
}
495493
496494
@override
497495
void onFriendRequestAccepted(String userName) {
498-
496+
499497
}
500498
501499
@override
502500
void onFriendRequestDeclined(String userName) {
503-
501+
504502
}
505503
}
506504
```
@@ -1072,7 +1070,6 @@ class _PageState extends State<Page> implements EMGroupEventListener {
10721070
@override
10731071
void onWhiteListRemovedFromGroup(String groupId, List<String> members) {}
10741072
}
1075-
10761073
```
10771074

10781075
#### 同意加群申请
@@ -1421,7 +1418,6 @@ class _PageState extends State<Page> implements EMChatRoomEventListener {
14211418
@override
14221419
void onWhiteListRemovedFromChatRoom(String roomId, List<String> members) {}
14231420
}
1424-
14251421
```
14261422

14271423
### 推送
@@ -1522,10 +1518,6 @@ try {
15221518
List<String> list = await EMClient.getInstance.pushManager.getNoPushUsersFromCache();
15231519
```
15241520

1525-
1526-
1527-
1528-
15291521
### EMUserInfoManager
15301522

15311523
#### 更新自己的用户属性
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
1+
12
import UIKit
23
import Flutter
4+
// 引入环信SDK
5+
import HyphenateChat
36

47
@UIApplicationMain
58
@objc class AppDelegate: FlutterAppDelegate {
69
override func application(
710
_ application: UIApplication,
811
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
912
) -> Bool {
10-
GeneratedPluginRegistrant.register(with: self)
13+
GeneratedPluginRegistrant.register(with: self);
14+
15+
// 获取UNUserNotificationCenter并申请[badge, alert, sound]权限。
16+
let center = UNUserNotificationCenter.current();
17+
center.requestAuthorization(options: [.badge, .alert, .sound]) { granted, error in
18+
if(granted){
19+
DispatchQueue.main.async {
20+
// 注册远程推送
21+
application.registerForRemoteNotifications();
22+
}
23+
}
24+
}
25+
1126
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
1227
}
28+
// 收到系统deviceToken获取成功回调
29+
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
30+
// 将deviceToken传给环信SDK
31+
EMClient.share.registerForRemoteNotifications(withDeviceToken: deviceToken, completion: nil)
32+
}
1333
}
34+
35+
36+

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class EaseIMDemo extends StatelessWidget {
5252
},
5353
child: ScreenUtilInit(
5454
designSize: Size(375, 667),
55-
builder: () {
55+
builder: (context) {
5656
return MaterialApp(
5757
builder: (context, child) => FlutterSmartDialog(child: child),
5858
debugShowCheckedModeBanner: false,

example/lib/pages/chat/chat_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class _ChatPageState extends State<ChatPage>
447447
print('_moreCameraBtnOnTap');
448448

449449
var curser = await EMClient.getInstance.groupManager
450-
.getGroupMemberListFromServer(widget.conversation.id);
450+
.fetchMemberListFromServer(widget.conversation.id);
451451

452452
debugPrint(curser.data.toString());
453453
}

example/lib/pages/conversations/conversations_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ConversationPageState extends State<ConversationPage>
6262
[
6363
PopMenuItem('创建群组'),
6464
PopMenuItem('添加好友'),
65-
PopMenuItem('多人通话'),
65+
// PopMenuItem('多人通话'),
6666
],
6767
callback: (index) {
6868
if (index == 0) {

example/lib/pages/group/joined_groups_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class JoinedGroupsPageState extends State<JoinedGroupsPage> {
239239
}
240240

241241
List<EMGroup> groups =
242-
await EMClient.getInstance.groupManager.getJoinedGroupsFromServer(
242+
await EMClient.getInstance.groupManager.fetchJoinedGroupsFromServer(
243243
pageSize: _pageSize,
244244
pageNum: _pageNumber,
245245
);

0 commit comments

Comments
 (0)