Skip to content

Commit 04cdd91

Browse files
committed
Fix ios
1 parent 58d0bee commit 04cdd91

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/ios/AppDelegate+FirebaseMessagingPlugin.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#import "FirebaseMessagingPlugin.h"
33
#import <objc/runtime.h>
44

5+
@import FirebaseCore;
6+
57
@implementation AppDelegate (FirebaseMessagingPlugin)
68

79
// Borrowed from http://nshipster.com/method-swizzling/
@@ -36,8 +38,21 @@ + (void)load {
3638
- (BOOL)identity_application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
3739
// always call original method implementation first
3840
BOOL handled = [self identity_application:application didFinishLaunchingWithOptions:launchOptions];
41+
if(![FIRApp defaultApp]) {
42+
[FIRApp configure];
43+
}
3944

45+
[FIRMessaging messaging].delegate = self;
4046
[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];
4156

4257
// if (launchOptions) {
4358
// NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];

src/ios/FirebaseMessagingPlugin.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ @implementation FirebaseMessagingPlugin
99

1010
- (void)pluginInitialize {
1111
NSLog(@"Starting Firebase Messaging plugin");
12-
13-
if(![FIRApp defaultApp]) {
14-
[FIRApp configure];
15-
}
1612
}
1713

1814
- (void)requestPermission:(CDVInvokedUrlCommand *)command {

0 commit comments

Comments
 (0)