@@ -287,6 +287,14 @@ static void AppDelegateApplicationDidBecomeActive(id self, SEL selector_value,
287
287
if (app_delegate_application_did_become_active) {
288
288
((util::AppDelegateApplicationDidBecomeActiveFunc)app_delegate_application_did_become_active)(
289
289
self, selector_value, application);
290
+ } else if ([self methodForSelector: @selector (forwardInvocation: )] !=
291
+ [NSObject instanceMethodForSelector: @selector (forwardInvocation: )]) {
292
+ NSMethodSignature *signature = [[self class ] instanceMethodSignatureForSelector: selector_value];
293
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: signature];
294
+ [invocation setSelector: selector_value];
295
+ [invocation setTarget: self ];
296
+ [invocation setArgument: &application atIndex: 2 ];
297
+ [self forwardInvocation: invocation];
290
298
}
291
299
}
292
300
@@ -298,6 +306,14 @@ static void AppDelegateApplicationDidEnterBackground(id self, SEL selector_value
298
306
if (app_delegate_application_did_enter_background) {
299
307
((util::AppDelegateApplicationDidEnterBackgroundFunc)
300
308
app_delegate_application_did_enter_background)(self, selector_value, application);
309
+ } else if ([self methodForSelector: @selector (forwardInvocation: )] !=
310
+ [NSObject instanceMethodForSelector: @selector (forwardInvocation: )]) {
311
+ NSMethodSignature *signature = [[self class ] instanceMethodSignatureForSelector: selector_value];
312
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: signature];
313
+ [invocation setSelector: selector_value];
314
+ [invocation setTarget: self ];
315
+ [invocation setArgument: &application atIndex: 2 ];
316
+ [self forwardInvocation: invocation];
301
317
}
302
318
if (MessagingIsInitialized ()) {
303
319
LogInfo (" FCM: Disconnect FCM service" );
@@ -341,6 +357,15 @@ static void AppDelegateApplicationDidRegisterForRemoteNotificationsWithDeviceTok
341
357
((util::AppDelegateApplicationDidRegisterForRemoteNotificationsWithDeviceTokenFunc)
342
358
app_delegate_application_did_register_for_remote_notifications_with_device_token)(
343
359
self, selector_value, application, deviceToken);
360
+ } else if ([self methodForSelector: @selector (forwardInvocation: )] !=
361
+ [NSObject instanceMethodForSelector: @selector (forwardInvocation: )]) {
362
+ NSMethodSignature *signature = [[self class ] instanceMethodSignatureForSelector: selector_value];
363
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: signature];
364
+ [invocation setSelector: selector_value];
365
+ [invocation setTarget: self ];
366
+ [invocation setArgument: &application atIndex: 2 ];
367
+ [invocation setArgument: &deviceToken atIndex: 3 ];
368
+ [self forwardInvocation: invocation];
344
369
}
345
370
}
346
371
@@ -358,6 +383,15 @@ static void AppDelegateApplicationDidFailToRegisterForRemoteNotificationsWithErr
358
383
((util::AppDelegateApplicationDidFailToRegisterForRemoteNotificationsWithErrorFunc)
359
384
app_delegate_application_did_fail_to_register_for_remote_notifications_with_error)(
360
385
self, selector_value, application, error);
386
+ } else if ([self methodForSelector: @selector (forwardInvocation: )] !=
387
+ [NSObject instanceMethodForSelector: @selector (forwardInvocation: )]) {
388
+ NSMethodSignature *signature = [[self class ] instanceMethodSignatureForSelector: selector_value];
389
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: signature];
390
+ [invocation setSelector: selector_value];
391
+ [invocation setTarget: self ];
392
+ [invocation setArgument: &application atIndex: 2 ];
393
+ [invocation setArgument: &error atIndex: 3 ];
394
+ [self forwardInvocation: invocation];
361
395
}
362
396
}
363
397
@@ -475,7 +509,7 @@ static BOOL AppDelegateApplicationDidFinishLaunchingWithOptions(id self, SEL sel
475
509
NSDictionary *launch_options) {
476
510
// Set up Messaging on iOS 10, if possible.
477
511
Class notification_center_class = NSClassFromString (@" UNUserNotificationCenter" );
478
- if (notification_center_class) {
512
+ if (notification_center_class && application ) {
479
513
LogInfo (" Setting up iOS 10 message delegate." );
480
514
481
515
// Cache the existing delegate if one exists it so we can pass along messages when needed.
@@ -499,6 +533,19 @@ static BOOL AppDelegateApplicationDidFinishLaunchingWithOptions(id self, SEL sel
499
533
return ((util::AppDelegateApplicationDidFinishLaunchingWithOptionsFunc)
500
534
app_delegate_application_did_finish_launching_with_options)(
501
535
self, selector_value, application, launch_options);
536
+ } else if ([self methodForSelector: @selector (forwardInvocation: )] !=
537
+ [NSObject instanceMethodForSelector: @selector (forwardInvocation: )]) {
538
+ NSMethodSignature *signature = [[self class ] instanceMethodSignatureForSelector: selector_value];
539
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: signature];
540
+ [invocation setSelector: selector_value];
541
+ [invocation setTarget: self ];
542
+ [invocation setArgument: &application atIndex: 2 ];
543
+ [invocation setArgument: &launch_options atIndex: 3 ];
544
+ [self forwardInvocation: invocation];
545
+ // Read the return value from the invocation.
546
+ BOOL ret = NO ;
547
+ [invocation getReturnValue: &ret];
548
+ return ret;
502
549
}
503
550
return NO ;
504
551
}
@@ -525,6 +572,15 @@ static void AppDelegateApplicationDidReceiveRemoteNotification(id self, SEL sele
525
572
((util::AppDelegateApplicationDidReceiveRemoteNotificationFunc)
526
573
app_delegate_application_did_receive_remote_notification)(self, selector_value,
527
574
application, user_info);
575
+ } else if ([self methodForSelector: @selector (forwardInvocation: )] !=
576
+ [NSObject instanceMethodForSelector: @selector (forwardInvocation: )]) {
577
+ NSMethodSignature *signature = [[self class ] instanceMethodSignatureForSelector: selector_value];
578
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: signature];
579
+ [invocation setSelector: selector_value];
580
+ [invocation setTarget: self ];
581
+ [invocation setArgument: &application atIndex: 2 ];
582
+ [invocation setArgument: &user_info atIndex: 3 ];
583
+ [self forwardInvocation: invocation];
528
584
}
529
585
}
530
586
@@ -550,6 +606,16 @@ static void AppDelegateApplicationDidReceiveRemoteNotificationFetchCompletionHan
550
606
((util::AppDelegateApplicationDidReceiveRemoteNotificationFetchCompletionHandlerFunc)
551
607
app_delegate_application_did_receive_remote_notification_fetch_completion_handler)(
552
608
self, selector_value, application, user_info, handler);
609
+ } else if ([self methodForSelector: @selector (forwardInvocation: )] !=
610
+ [NSObject instanceMethodForSelector: @selector (forwardInvocation: )]) {
611
+ NSMethodSignature *signature = [[self class ] instanceMethodSignatureForSelector: selector_value];
612
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: signature];
613
+ [invocation setSelector: selector_value];
614
+ [invocation setTarget: self ];
615
+ [invocation setArgument: &application atIndex: 2 ];
616
+ [invocation setArgument: &user_info atIndex: 3 ];
617
+ [invocation setArgument: &handler atIndex: 4 ];
618
+ [self forwardInvocation: invocation];
553
619
} else {
554
620
// TODO(smiles): We should determine whether the entire message is sent to this notification
555
621
// method, if not this is clearly wrong and will need to download the rest of the message.
0 commit comments