diff options
author | Ryan Wilson <wilsonryan@google.com> | 2017-07-26 22:17:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-26 22:17:48 -0400 |
commit | 94dd3c50ad22533f97f59988a1dc01277f29ed6d (patch) | |
tree | 048f2e6278a6fe9c24368f6f9ea01e5098f2b8d7 | |
parent | dec86df5539dcc6fc73085f14a180568e253398a (diff) |
Configure Messaging for default FIRApp only. (#154)
Currently Messaging will use the most recent FIRApp configured which
isn't obvious. This will limit it to only the defualt FIRApp.
-rw-r--r-- | Firebase/Messaging/FIRMMessageCode.h | 1 | ||||
-rw-r--r-- | Firebase/Messaging/FIRMessaging+FIRApp.m | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Firebase/Messaging/FIRMMessageCode.h b/Firebase/Messaging/FIRMMessageCode.h index d0e91a3..7a2a8c5 100644 --- a/Firebase/Messaging/FIRMMessageCode.h +++ b/Firebase/Messaging/FIRMMessageCode.h @@ -19,6 +19,7 @@ typedef NS_ENUM(NSInteger, FIRMessagingMessageCode) { // FIRMessaging+FIRApp.m kFIRMessagingMessageCodeFIRApp000 = 1000, // I-FCM001000 + kFIRMessagingMessageCodeFIRApp001 = 1001, // I-FCM001001 // FIRMessaging.m kFIRMessagingMessageCodeMessaging000 = 2000, // I-FCM002000 kFIRMessagingMessageCodeMessaging001 = 2001, // I-FCM002001 diff --git a/Firebase/Messaging/FIRMessaging+FIRApp.m b/Firebase/Messaging/FIRMessaging+FIRApp.m index b8adf14..50078bf 100644 --- a/Firebase/Messaging/FIRMessaging+FIRApp.m +++ b/Firebase/Messaging/FIRMessaging+FIRApp.m @@ -44,6 +44,14 @@ + (void)didReceiveConfigureSDKNotification:(NSNotification *)notification { NSDictionary *appInfoDict = notification.userInfo; + NSNumber *isDefaultApp = appInfoDict[kFIRAppIsDefaultAppKey]; + if (![isDefaultApp boolValue]) { + // Only configure for the default FIRApp. + FIRMessagingLoggerDebug(kFIRMessagingMessageCodeFIRApp001, + @"Firebase Messaging only works with the default app."); + return; + } + NSString *appName = appInfoDict[kFIRAppNameKey]; FIRApp *app = [FIRApp appNamed:appName]; [[FIRMessaging messaging] configureMessaging:app]; |