Skip to content

Commit 67ae955

Browse files
[Messaging] Standalone Watch App Sample (#10552)
* [Messaging] Standalone Watch App Sample * Add comment on disabling method swizzling * Add dividers * Rename to notificationCenter * Add README with instructions * Fix whitespace * #no-changelog, build regression test * fixes to yml and scripts for sample * Add podfile * podfile fixes * podfile fixes * Make project format xcode 13 compatible * fix scheme in build.sh * fix reference to service info file * fix assets compile failure * fix podfile linkage Co-authored-by: Peter Friese <[email protected]>
1 parent 8de8f50 commit 67ae955

File tree

15 files changed

+734
-0
lines changed

15 files changed

+734
-0
lines changed

.github/workflows/messaging.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,27 @@ jobs:
229229
run: scripts/install_prereqs.sh SwiftUISample iOS
230230
- name: Build
231231
run: ([ -z $plist_secret ] || scripts/build.sh SwiftUISample iOS)
232+
233+
messaging-watchos-standalone-sample-build-test:
234+
# Don't run on private repo unless it is a PR.
235+
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
236+
env:
237+
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
238+
runs-on: macos-12
239+
steps:
240+
- uses: actions/checkout@v3
241+
- uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
242+
with:
243+
cache_key: ${{ matrix.os }}
244+
- uses: ruby/setup-ruby@v1
245+
- name: Setup Bundler
246+
run: scripts/setup_bundler.sh
247+
- name: Install Secret GoogleService-Info.plist
248+
run: |
249+
scripts/decrypt_gha_secret.sh scripts/gha-encrypted/messaging-sample-plist.gpg \
250+
FirebaseMessaging/Apps/Shared/GoogleService-Info.plist "$plist_secret"
251+
- name: Prereqs
252+
run: scripts/install_prereqs.sh MessagingSampleStandaloneWatchApp watchOS
253+
- name: Build
254+
run: ([ -z $plist_secret ] || scripts/build.sh MessagingSampleStandaloneWatchApp watchOS)
255+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ FirebaseMessaging/Tests/IntegrationTests/Resources/GoogleService-Info.plist
2626
FirebaseMessaging/Apps/Shared/GoogleService-Info.plist
2727
FirebaseMessaging/Apps/AdvancedSample/SampleWatchWatchKitExtension/GoogleService-Info.plist
2828
FirebaseMessaging/Apps/AdvancedSample/AppClips/GoogleService-Info.plist
29+
FirebaseMessaging/Apps/SampleStandaloneWatchApp/SampleStandaloneWatchAppWatchApp/GoogleService-Info.plist
2930

3031
# Credentials for Firebase Storage Integration Tests
3132
FirebaseStorage/Tests/ObjCIntegration/Credentials.h
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use_frameworks!
2+
3+
source 'https://github.com/firebase/SpecsDev.git'
4+
source 'https://github.com/firebase/SpecsStaging.git'
5+
source 'https://cdn.cocoapods.org/'
6+
7+
target 'SampleStandaloneWatchApp Watch App' do
8+
platform :watchos, '9.0'
9+
10+
pod 'FirebaseCore', :path => '../../../'
11+
pod 'FirebaseMessaging', :path => '../../../'
12+
pod 'FirebaseCoreInternal', :path => '../../../'
13+
pod 'FirebaseInstallations', :path => '../../../'
14+
15+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Sample Standalone watchOS App
2+
3+
This sample demonstrates how to use Firebase Cloud Messaging in a standalone watchOS app.
4+
5+
## Getting started
6+
7+
1. Turn on _Developer mode_ on your watch:
8+
- Settings > Privacy & Security > Developer Mode
9+
- You will have to restart your watch
10+
1. Change the bundle identifier to a unique ID (e.g. `dev.<yourcompany>.WatchKitApp.dev.WatchKitApp`)
11+
1. Enable automatic code signing for the Xcode project
12+
1. [Add Firebase to your watchOS Project](https://firebase.google.com/docs/ios/setup)
13+
> **Warning**
14+
> Make sure to add the `GoogleServices-Info.plist` file to the `SampleStandaloneWatchApp Watch App` target
15+
1. [Upload your APNs authentication key to Firebase](https://firebase.google.com/docs/cloud-messaging/ios/client#upload_your_apns_authentication_key)
16+
1. Run the app
17+
1. When the app first launches, you will need to accept the notification permission
18+
1. In the Firebase console, go to [Messaging](https://console.firebase.google.com/project/_/messaging/onboarding), and click on _Create your first campaign_
19+
1. Select _Firebase Notification messages_ and click on _Create_
20+
1. Enter a message in the _Notification text_ field
21+
1. Click on the blue _Send test message_ button on the right
22+
> **Note**
23+
> It is easy to miss this button. You have to click on the blue **Send test message** button on the **RIGHT HAND** side of the screen.
24+
1. In the Xcode debug console, find the _FCM registration token_, and add it in the _Test on device_ dialog
25+
1. Tick the checkbox for the token, then click on the _Test_ button
26+
1. The message should now appear on your development watch
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>FirebaseAppDelegateProxyEnabled</key>
6+
<false/>
7+
<key>UIBackgroundModes</key>
8+
<array>
9+
<string>remote-notification</string>
10+
</array>
11+
</dict>
12+
</plist>

0 commit comments

Comments
 (0)