@@ -59,6 +59,7 @@ @implementation FLTFirebaseAuthPlugin {
59
59
NSObject <FlutterBinaryMessenger> *_binaryMessenger;
60
60
NSMutableDictionary <NSString *, FlutterEventChannel *> *_eventChannels;
61
61
NSMutableDictionary <NSString *, NSObject <FlutterStreamHandler> *> *_streamHandlers;
62
+ NSData *_apnsToken;
62
63
}
63
64
64
65
#pragma mark - FlutterPlugin
@@ -155,6 +156,8 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)flutter
155
156
FLTFirebaseMethodCallResult *methodCallResult =
156
157
[FLTFirebaseMethodCallResult createWithSuccess: successBlock andErrorBlock: errorBlock];
157
158
159
+ [self ensureAPNSTokenSetting ];
160
+
158
161
if ([@" Auth#registerIdTokenListener" isEqualToString: call.method]) {
159
162
[self registerIdTokenListener: call.arguments withMethodCallResult: methodCallResult];
160
163
} else if ([@" Auth#registerAuthStateListener" isEqualToString: call.method]) {
@@ -242,7 +245,7 @@ - (BOOL)application:(UIApplication *)application
242
245
243
246
- (void )application : (UIApplication *)application
244
247
didRegisterForRemoteNotificationsWithDeviceToken : (NSData *)deviceToken {
245
- [[FIRAuth auth ] setAPNSToken: deviceToken type: FIRAuthAPNSTokenTypeUnknown] ;
248
+ _apnsToken = deviceToken;
246
249
}
247
250
248
251
- (BOOL )application : (UIApplication *)app openURL : (NSURL *)url options : (NSDictionary *)options {
@@ -1285,4 +1288,16 @@ + (NSMutableDictionary *)getNSDictionaryFromUser:(FIRUser *)user {
1285
1288
return userData;
1286
1289
}
1287
1290
1291
+ - (void )ensureAPNSTokenSetting {
1292
+ #if !TARGET_OS_OSX
1293
+ FIRApp *defaultApp = [FIRApp defaultApp ];
1294
+ if (defaultApp) {
1295
+ if ([FIRAuth auth ].APNSToken == nil && _apnsToken != nil ) {
1296
+ [[FIRAuth auth ] setAPNSToken: _apnsToken type: FIRAuthAPNSTokenTypeUnknown];
1297
+ _apnsToken = nil ;
1298
+ }
1299
+ }
1300
+ #endif
1301
+ }
1302
+
1288
1303
@end
0 commit comments