Skip to content

Conversation

@aashishpatil-g
Copy link
Contributor

@aashishpatil-g aashishpatil-g commented Oct 7, 2022

Discussion

Fix for #10147

In versions of Xcode prior to Xcode 14, whenever a watch app was created, Xcode always created two targets
Watch App (contained assets for the app but no code)
Watch Kit Extension (contained the code / logic for the app)

Xcode 14 onwards, no watch kit extension target is created for watchOS apps. There is a consolidated Watch App target that contains both code and assets.

Firebase Messaging code used to strip out the watch extension suffix and use the watch app bundle ID for FCM registration. Since there is no extension anymore, the code is inadvertently stripping out the last component of the app bundle identifier itself, resulting in an incorrect bundle ID being used for FCM registration.

This change detects if code is running in an extension by looking for the watch kit NSExtensionPointIdentifier in the Info.plist before stripping out the last component of the bundle identifier.

Testing

  • Created a sample app with watch kit extension on Xcode 13 and confirmed that function returned YES (true) for extension.
  • Created a sample watch app (with no extension) on Xcode 14 and confirmed that function returned NO.

API Changes

None

@google-oss-bot
Copy link

google-oss-bot commented Oct 7, 2022

Coverage Report 1

Affected Products

  • FirebaseMessaging-iOS-FirebaseMessaging.framework

    Overall coverage changed from 63.64% (27c7302) to 63.89% (92dffd9) by +0.25%.

    FilenameBase (27c7302)Merge (92dffd9)Diff
    FIRMessagingPendingTopicsList.m89.02%89.80%+0.78%
    FIRMessagingTokenManager.m35.78%37.55%+1.77%
    FIRMessagingTokenOperation.m95.04%96.45%+1.42%
    FIRMessagingUtilities.m57.56%56.73%-0.84%

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/92FT8zAeco.html

Copy link
Member

@paulb777 paulb777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@aashishpatil-g aashishpatil-g changed the title Xcode 14 watchkit extension bundle id fix [Messaging] Xcode 14 watchkit extension bundle id fix Oct 10, 2022
Copy link
Contributor

@charlotteliang charlotteliang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending approval on testing on a real device.

Also please address the comment for older version for backward compatibility.

@aashishpatil-g
Copy link
Contributor Author

Tested on device for both old and new scenarios and confirmed that logic works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New Watch App project configuration from Xcode14 does not receive push notifications using Firebase Cloud Messaging

4 participants