2727static NSString *const kFIRMessagingAPNSSandboxPrefix = @" s_" ;
2828static NSString *const kFIRMessagingAPNSProdPrefix = @" p_" ;
2929
30+ static NSString *const kFIRMessagingWatchKitExtensionPoint = @" com.apple.watchkit" ;
31+
3032#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
3133static NSString *const kEntitlementsAPSEnvironmentKey = @" Entitlements.aps-environment" ;
3234#else
@@ -76,10 +78,14 @@ int64_t FIRMessagingCurrentTimestampInMilliseconds(void) {
7678NSString *FIRMessagingAppIdentifier (void ) {
7779 NSString *bundleID = [[NSBundle mainBundle ] bundleIdentifier ];
7880#if TARGET_OS_WATCH
79- // The code is running in watchKit extension target but the actually bundleID is in the watchKit
80- // target. So we need to remove the last part of the bundle ID in watchKit extension to match
81- // the one in watchKit target.
82- return FIRMessagingBundleIDByRemovingLastPartFrom (bundleID);
81+ if (FIRMessagingIsWatchKitExtension ()) {
82+ // The code is running in watchKit extension target but the actually bundleID is in the watchKit
83+ // target. So we need to remove the last part of the bundle ID in watchKit extension to match
84+ // the one in watchKit target.
85+ return FIRMessagingBundleIDByRemovingLastPartFrom (bundleID);
86+ } else {
87+ return bundleID;
88+ }
8389#else
8490 return bundleID;
8591#endif
@@ -89,6 +95,25 @@ int64_t FIRMessagingCurrentTimestampInMilliseconds(void) {
8995 return [FIROptions defaultOptions ].googleAppID ;
9096}
9197
98+ BOOL FIRMessagingIsWatchKitExtension (void ) {
99+ #if TARGET_OS_WATCH
100+ NSDictionary <NSString *, id > *infoDict = [[NSBundle mainBundle ] infoDictionary ];
101+ NSDictionary <NSString *, id > *extensionAttrDict = infoDict[@" NSExtension" ];
102+ if (!extensionAttrDict) {
103+ return NO ;
104+ }
105+
106+ NSString *extensionPointId = extensionAttrDict[@" NSExtensionPointIdentifier" ];
107+ if (extensionPointId) {
108+ return [extensionPointId isEqualToString: kFIRMessagingWatchKitExtensionPoint ];
109+ } else {
110+ return NO ;
111+ }
112+ #else
113+ return NO ;
114+ #endif
115+ }
116+
92117uint64_t FIRMessagingGetFreeDiskSpaceInMB (void ) {
93118 NSError *error;
94119 NSArray *paths =
0 commit comments