I've created a plugin which supoort Push Notification but application:didReceiveRemoteNotification:fetchCompletionHandler:
not fired The notification is received in the following cases only:
application:didReceiveRemoteNotification:
content_available
to true in the notification payload I'm just wondering why this is happening, can anyone help me to figure out how can I make it work with application:didReceiveRemoteNotification:fetchCompletionHandler:
?
Do you use FlutterAppDelegate as superclass of AppDelegte? In FlutterAppDelegate.mm, it replaced method respondsToSelector
like below
- (BOOL)respondsToSelector:(SEL)selector {
if ([_lifeCycleDelegate isSelectorAddedDynamically:selector]) {
return [self delegateRespondsSelectorToPlugins:selector];
}
return [super respondsToSelector:selector];
}
And there is implementation of in FlutterPluginAppLifeCycleDelegate
static const SEL selectorsHandledByPlugins[] = {
@selector(application:didReceiveRemoteNotification:fetchCompletionHandler:),
@selector(application:performFetchWithCompletionHandler:)};
- (BOOL)isSelectorAddedDynamically:(SEL)selector {
for (const SEL& aSelector : selectorsHandledByPlugins) {
if (selector == aSelector) {
return YES;
}
}
return NO;
}
So for calling of application:didReceiveRemoteNotification:fetchCompletionHandler:
it will call selctor in FlutterPluginAppLifeCycleDelegate
- (void)application:(UIApplication*)application
didReceiveRemoteNotification:(NSDictionary*)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([delegate respondsToSelector:_cmd]) {
if ([delegate application:application
didReceiveRemoteNotification:userInfo
fetchCompletionHandler:completionHandler]) {
return;
}
}
}
}
Maybe some plugins break the chain of calls. It's my guess base Flutter Engine source code and I do not confirm it in a debug build of flutter engine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.