File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 2
2
#import " FirebaseMessagingPlugin.h"
3
3
#import < objc/runtime.h>
4
4
5
+ @import FirebaseCore;
6
+
5
7
@implementation AppDelegate (FirebaseMessagingPlugin)
6
8
7
9
// Borrowed from http://nshipster.com/method-swizzling/
@@ -36,8 +38,21 @@ + (void)load {
36
38
- (BOOL )identity_application : (UIApplication *)application didFinishLaunchingWithOptions : (NSDictionary *)launchOptions {
37
39
// always call original method implementation first
38
40
BOOL handled = [self identity_application: application didFinishLaunchingWithOptions: launchOptions];
41
+ if (![FIRApp defaultApp ]) {
42
+ [FIRApp configure ];
43
+ }
39
44
45
+ [FIRMessaging messaging ].delegate = self;
40
46
[UNUserNotificationCenter currentNotificationCenter ].delegate = self;
47
+ UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
48
+ UNAuthorizationOptionSound | UNAuthorizationOptionBadge ;
49
+ [[UNUserNotificationCenter currentNotificationCenter ]
50
+ requestAuthorizationWithOptions: authOptions
51
+ completionHandler: ^(BOOL granted, NSError * _Nullable error) {
52
+ // ...
53
+ }];
54
+
55
+ [application registerForRemoteNotifications ];
41
56
42
57
// if (launchOptions) {
43
58
// NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
Original file line number Diff line number Diff line change @@ -9,10 +9,6 @@ @implementation FirebaseMessagingPlugin
9
9
10
10
- (void )pluginInitialize {
11
11
NSLog (@" Starting Firebase Messaging plugin" );
12
-
13
- if (![FIRApp defaultApp ]) {
14
- [FIRApp configure ];
15
- }
16
12
}
17
13
18
14
- (void )requestPermission : (CDVInvokedUrlCommand *)command {
You can’t perform that action at this time.
0 commit comments