Skip to content

Commit dbc1d41

Browse files
Add service extension, app clips and watch app to Messaging advanced sample app (#7187)
1 parent 1bfc11d commit dbc1d41

File tree

46 files changed

+1553
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1553
-15
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Example/InstanceID/Resources/GoogleService-Info.plist
2323
FirebaseMessaging/Tests/IntegrationTests/Resources/GoogleService-Info.plist
2424
# FirebaseMessaging test app GoogleService-Info.plist
2525
FirebaseMessaging/Apps/Shared/GoogleService-Info.plist
26-
26+
FirebaseMessaging/Apps/AdvancedSample/SampleWatchWatchKitExtension/GoogleService-Info.plist
27+
FirebaseMessaging/Apps/AdvancedSample/AppClips/GoogleService-Info.plist
2728

2829
# Credentials for Firebase Storage Integration Tests
2930
FirebaseStorage/Tests/Integration/Credentials.h

FirebaseMessaging/Apps/AdvancedSample/AdvancedSample.xcodeproj/project.pbxproj

Lines changed: 736 additions & 6 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1230"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "51A1F39725883DCE0025932B"
18+
BuildableName = "AdvancedSample.app"
19+
BlueprintName = "AdvancedSample"
20+
ReferencedContainer = "container:AdvancedSample.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "51A1F39725883DCE0025932B"
48+
BuildableName = "AdvancedSample.app"
49+
BlueprintName = "AdvancedSample"
50+
ReferencedContainer = "container:AdvancedSample.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
<CommandLineArguments>
54+
<CommandLineArgument
55+
argument = "-FIRDebugEnabled"
56+
isEnabled = "YES">
57+
</CommandLineArgument>
58+
</CommandLineArguments>
59+
</LaunchAction>
60+
<ProfileAction
61+
buildConfiguration = "Release"
62+
shouldUseLaunchSchemeArgsEnv = "YES"
63+
savedToolIdentifier = ""
64+
useCustomWorkingDirectory = "NO"
65+
debugDocumentVersioning = "YES">
66+
<BuildableProductRunnable
67+
runnableDebuggingMode = "0">
68+
<BuildableReference
69+
BuildableIdentifier = "primary"
70+
BlueprintIdentifier = "51A1F39725883DCE0025932B"
71+
BuildableName = "AdvancedSample.app"
72+
BlueprintName = "AdvancedSample"
73+
ReferencedContainer = "container:AdvancedSample.xcodeproj">
74+
</BuildableReference>
75+
</BuildableProductRunnable>
76+
</ProfileAction>
77+
<AnalyzeAction
78+
buildConfiguration = "Debug">
79+
</AnalyzeAction>
80+
<ArchiveAction
81+
buildConfiguration = "Release"
82+
revealArchiveInOrganizer = "YES">
83+
</ArchiveAction>
84+
</Scheme>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1230"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "51944904258AF0B100297021"
18+
BuildableName = "AppClips.app"
19+
BlueprintName = "AppClips"
20+
ReferencedContainer = "container:AdvancedSample.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "51944904258AF0B100297021"
48+
BuildableName = "AppClips.app"
49+
BlueprintName = "AppClips"
50+
ReferencedContainer = "container:AdvancedSample.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
<CommandLineArguments>
54+
<CommandLineArgument
55+
argument = "-FIRDebugEnabled"
56+
isEnabled = "YES">
57+
</CommandLineArgument>
58+
</CommandLineArguments>
59+
<EnvironmentVariables>
60+
<EnvironmentVariable
61+
key = "_XCAppClipURL"
62+
value = "https://example.com"
63+
isEnabled = "NO">
64+
</EnvironmentVariable>
65+
</EnvironmentVariables>
66+
</LaunchAction>
67+
<ProfileAction
68+
buildConfiguration = "Release"
69+
shouldUseLaunchSchemeArgsEnv = "YES"
70+
savedToolIdentifier = ""
71+
useCustomWorkingDirectory = "NO"
72+
debugDocumentVersioning = "YES">
73+
<BuildableProductRunnable
74+
runnableDebuggingMode = "0">
75+
<BuildableReference
76+
BuildableIdentifier = "primary"
77+
BlueprintIdentifier = "51944904258AF0B100297021"
78+
BuildableName = "AppClips.app"
79+
BlueprintName = "AppClips"
80+
ReferencedContainer = "container:AdvancedSample.xcodeproj">
81+
</BuildableReference>
82+
</BuildableProductRunnable>
83+
</ProfileAction>
84+
<AnalyzeAction
85+
buildConfiguration = "Debug">
86+
</AnalyzeAction>
87+
<ArchiveAction
88+
buildConfiguration = "Release"
89+
revealArchiveInOrganizer = "YES">
90+
</ArchiveAction>
91+
</Scheme>
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>aps-environment</key>
6+
<string>development</string>
7+
<key>com.apple.developer.parent-application-identifiers</key>
8+
<array>
9+
<string>$(AppIdentifierPrefix)com.google.firebase.extensions.dev</string>
10+
</array>
11+
</dict>
12+
</plist>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21+
</objects>
22+
<point key="canvasLocation" x="53" y="375"/>
23+
</scene>
24+
</scenes>
25+
</document>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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> NSAppClipRequestEphemeralUserNotification </key>
6+
<true/>
7+
<key>CFBundleDevelopmentRegion</key>
8+
<string>$(DEVELOPMENT_LANGUAGE)</string>
9+
<key>CFBundleDisplayName</key>
10+
<string>AdvancedSample</string>
11+
<key>CFBundleExecutable</key>
12+
<string>$(EXECUTABLE_NAME)</string>
13+
<key>CFBundleIdentifier</key>
14+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
15+
<key>CFBundleInfoDictionaryVersion</key>
16+
<string>6.0</string>
17+
<key>CFBundleName</key>
18+
<string>$(PRODUCT_NAME)</string>
19+
<key>CFBundlePackageType</key>
20+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
21+
<key>CFBundleShortVersionString</key>
22+
<string>1.0</string>
23+
<key>CFBundleVersion</key>
24+
<string>1</string>
25+
<key>LSRequiresIPhoneOS</key>
26+
<true/>
27+
<key>NSAppClip</key>
28+
<dict>
29+
<key>NSAppClipRequestEphemeralUserNotification</key>
30+
<false/>
31+
<key>NSAppClipRequestLocationConfirmation</key>
32+
<false/>
33+
</dict>
34+
<key>UIApplicationSceneManifest</key>
35+
<dict>
36+
<key>UIApplicationSupportsMultipleScenes</key>
37+
<false/>
38+
<key>UISceneConfigurations</key>
39+
<dict>
40+
<key>UIWindowSceneSessionRoleApplication</key>
41+
<array>
42+
<dict>
43+
<key>UISceneConfigurationName</key>
44+
<string>Default Configuration</string>
45+
<key>UISceneDelegateClassName</key>
46+
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
47+
</dict>
48+
</array>
49+
</dict>
50+
</dict>
51+
<key>UIApplicationSupportsIndirectInputEvents</key>
52+
<true/>
53+
<key>UILaunchStoryboardName</key>
54+
<string>LaunchScreen</string>
55+
<key>UIRequiredDeviceCapabilities</key>
56+
<array>
57+
<string>armv7</string>
58+
</array>
59+
<key>UISupportedInterfaceOrientations</key>
60+
<array>
61+
<string>UIInterfaceOrientationPortrait</string>
62+
<string>UIInterfaceOrientationLandscapeLeft</string>
63+
<string>UIInterfaceOrientationLandscapeRight</string>
64+
</array>
65+
<key>UISupportedInterfaceOrientations~ipad</key>
66+
<array>
67+
<string>UIInterfaceOrientationPortrait</string>
68+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
69+
<string>UIInterfaceOrientationLandscapeLeft</string>
70+
<string>UIInterfaceOrientationLandscapeRight</string>
71+
</array>
72+
</dict>
73+
</plist>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>NotificationServiceExtension</string>
9+
<key>CFBundleExecutable</key>
10+
<string>$(EXECUTABLE_NAME)</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
<key>NSExtension</key>
24+
<dict>
25+
<key>NSExtensionPointIdentifier</key>
26+
<string>com.apple.usernotifications.service</string>
27+
<key>NSExtensionPrincipalClass</key>
28+
<string>$(PRODUCT_MODULE_NAME).NotificationService</string>
29+
</dict>
30+
</dict>
31+
</plist>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import UserNotifications
16+
import FirebaseMessaging
17+
18+
class NotificationService: UNNotificationServiceExtension {
19+
var contentHandler: ((UNNotificationContent) -> Void)?
20+
var bestAttemptContent: UNMutableNotificationContent?
21+
22+
override func didReceive(_ request: UNNotificationRequest,
23+
withContentHandler contentHandler: @escaping (UNNotificationContent)
24+
-> Void) {
25+
self.contentHandler = contentHandler
26+
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
27+
28+
if let bestAttemptContent = bestAttemptContent {
29+
// Modify the notification content here...
30+
bestAttemptContent.title = "\(bestAttemptContent.title) 👩🏻‍💻"
31+
32+
Messaging.serviceExtension()
33+
.populateNotificationContent(bestAttemptContent, withContentHandler: contentHandler)
34+
}
35+
}
36+
37+
override func serviceExtensionTimeWillExpire() {
38+
// Called just before the extension will be terminated by the system.
39+
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
40+
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
41+
contentHandler(bestAttemptContent)
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)