easemob / im_flutter_sdk

环信im flutter sdk, example中包含ui代码.
MIT License
237 stars 85 forks source link

Plugin中的FlutterAppDelegate 的分类EaseMob 的方法覆盖了FlutterAppDelegate中的方法 ,收不到注册远程通知的回调,获取不到token, #479

Closed demoYang closed 1 year ago

demoYang commented 2 years ago

image image

如图, Plugin ImFlutterSdkPlugin.m 文件中有个FlutterAppDelegate 的分类EaseMob ,导致 FlutterAppDelegate 自己的 -application: didRegisterForRemoteNotificationsWithDeviceToken: 方法没有走,

demoYang commented 2 years ago

Flutter Plugin im_flutter_sdk version : 3.8.3+2

dujiepeng commented 2 years ago

@demoYang 是的,这是为了开启环信消息推送。这会导致其他地方的注册不回调,如果您需要使用其他的,可以直接把这部分代码移到需要的地方。只要确保把deviceToken传给环信sdk就行。

demoYang commented 2 years ago
@implementation ImFlutterSdkPlugin

+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
    ImFlutterSdkPlugin* imPlugin = [[ImFlutterSdkPlugin alloc] init];
    [registrar addApplicationDelegate:imPlugin];
    [EMClientWrapper channelName:EMChannelName(@"em_client") registrar:registrar];
}

- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [[EMClient sharedClient] applicationDidEnterBackground:application];
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [[EMClient sharedClient] applicationWillEnterForeground:application];
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [[EMClient sharedClient] bindDeviceToken:deviceToken];
    });
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    NSLog(@"注册推送失败 --- %@", error);
}
@end