Skip to content

Commit

Permalink
test: update sample app with 3rd party SDK that handles push (#105)
Browse files Browse the repository at this point in the history
Part of iOS automatic push click handling feature introduced in version 2.11
  • Loading branch information
levibostian committed Feb 12, 2024
1 parent 4828a3c commit 9967675
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 49 deletions.
196 changes: 188 additions & 8 deletions apps/amiapp_flutter/android/app/google-services.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,42 @@
"storage_bucket": "remote-habits.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:1001564516023:android:a021e40983dfcc781a2732",
"android_client_info": {
"package_name": "com.cio.unit"
}
},
"oauth_client": [
{
"client_id": "1001564516023-59nace30peq2pfenpruv72hkbma4ocfd.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyASGdGzS1zfpzNdZTXtthSWEHs3b0mmOGA"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1001564516023-59nace30peq2pfenpruv72hkbma4ocfd.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "1001564516023-4ec1vok624lq3sg3lu8mc8gbtn07bkbn.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "io.customer.rn-sample.fcm"
}
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:1001564516023:android:7cfa09512576cfdb1a2732",
Expand All @@ -31,10 +67,10 @@
"client_type": 3
},
{
"client_id": "1001564516023-5n3nd9b1d58s4pb776qpld55vuvrk45u.apps.googleusercontent.com",
"client_id": "1001564516023-4ec1vok624lq3sg3lu8mc8gbtn07bkbn.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "io.customer.ios-sample.cocoapods-fcm"
"bundle_id": "io.customer.rn-sample.fcm"
}
}
]
Expand Down Expand Up @@ -67,10 +103,10 @@
"client_type": 3
},
{
"client_id": "1001564516023-5n3nd9b1d58s4pb776qpld55vuvrk45u.apps.googleusercontent.com",
"client_id": "1001564516023-4ec1vok624lq3sg3lu8mc8gbtn07bkbn.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "io.customer.ios-sample.cocoapods-fcm"
"bundle_id": "io.customer.rn-sample.fcm"
}
}
]
Expand Down Expand Up @@ -103,10 +139,82 @@
"client_type": 3
},
{
"client_id": "1001564516023-5n3nd9b1d58s4pb776qpld55vuvrk45u.apps.googleusercontent.com",
"client_id": "1001564516023-4ec1vok624lq3sg3lu8mc8gbtn07bkbn.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "io.customer.rn-sample.fcm"
}
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:1001564516023:android:0b41c62a5570b80f1a2732",
"android_client_info": {
"package_name": "io.customer.android.sample.java_layout"
}
},
"oauth_client": [
{
"client_id": "1001564516023-59nace30peq2pfenpruv72hkbma4ocfd.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyASGdGzS1zfpzNdZTXtthSWEHs3b0mmOGA"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1001564516023-59nace30peq2pfenpruv72hkbma4ocfd.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "1001564516023-4ec1vok624lq3sg3lu8mc8gbtn07bkbn.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "io.customer.rn-sample.fcm"
}
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:1001564516023:android:52a211f8e5cf7b431a2732",
"android_client_info": {
"package_name": "io.customer.android.sample.kotlin_compose"
}
},
"oauth_client": [
{
"client_id": "1001564516023-59nace30peq2pfenpruv72hkbma4ocfd.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyASGdGzS1zfpzNdZTXtthSWEHs3b0mmOGA"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1001564516023-59nace30peq2pfenpruv72hkbma4ocfd.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "1001564516023-4ec1vok624lq3sg3lu8mc8gbtn07bkbn.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "io.customer.ios-sample.cocoapods-fcm"
"bundle_id": "io.customer.rn-sample.fcm"
}
}
]
Expand Down Expand Up @@ -139,10 +247,82 @@
"client_type": 3
},
{
"client_id": "1001564516023-5n3nd9b1d58s4pb776qpld55vuvrk45u.apps.googleusercontent.com",
"client_id": "1001564516023-4ec1vok624lq3sg3lu8mc8gbtn07bkbn.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "io.customer.rn-sample.fcm"
}
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:1001564516023:android:2835273f9d64bb631a2732",
"android_client_info": {
"package_name": "io.customer.rn_sample.fcm"
}
},
"oauth_client": [
{
"client_id": "1001564516023-59nace30peq2pfenpruv72hkbma4ocfd.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyASGdGzS1zfpzNdZTXtthSWEHs3b0mmOGA"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1001564516023-59nace30peq2pfenpruv72hkbma4ocfd.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "1001564516023-4ec1vok624lq3sg3lu8mc8gbtn07bkbn.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "io.customer.rn-sample.fcm"
}
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:1001564516023:android:bce0de5f8642156a1a2732",
"android_client_info": {
"package_name": "io.customer.rn_sample.typescript"
}
},
"oauth_client": [
{
"client_id": "1001564516023-59nace30peq2pfenpruv72hkbma4ocfd.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyASGdGzS1zfpzNdZTXtthSWEHs3b0mmOGA"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1001564516023-59nace30peq2pfenpruv72hkbma4ocfd.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "1001564516023-4ec1vok624lq3sg3lu8mc8gbtn07bkbn.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "io.customer.ios-sample.cocoapods-fcm"
"bundle_id": "io.customer.rn-sample.fcm"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions apps/amiapp_flutter/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ target 'Runner' do
use_modular_headers!

# Uncomment only 1 of the lines below to install a version of the iOS SDK
pod 'CustomerIO/MessagingPushFCM', '~> 2' # install production build
pod 'CustomerIO/MessagingPushFCM', '~> 2.11' # install production build
# install_non_production_ios_sdk_local_path(local_path: '~/code/customerio-ios/', is_app_extension: false, push_service: "fcm")
# install_non_production_ios_sdk_git_branch(branch_name: 'name-of-ios-sdk-branch', is_app_extension: false, push_service: "fcm")

Expand All @@ -50,7 +50,7 @@ end
target 'NotificationServiceExtension' do
use_frameworks!
# Uncomment only 1 of the lines below to install a version of the iOS SDK
pod 'CustomerIO/MessagingPushFCM', '~> 2' # install production build
pod 'CustomerIO/MessagingPushFCM', '~> 2.11' # install production build
# install_non_production_ios_sdk_local_path(local_path: '~/code/customerio-ios/', is_app_extension: true, push_service: "fcm")
# install_non_production_ios_sdk_git_branch(branch_name: 'name-of-ios-sdk-branch', is_app_extension: true, push_service: "fcm")
end
Expand Down
8 changes: 4 additions & 4 deletions apps/amiapp_flutter/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
objects = {

/* Begin PBXBuildFile section */
0888D1012BEC428D66F8D1ED /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6615E32455EADFC1FBDD78CC /* GoogleService-Info.plist */; };
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
28EF97E17CEA8AA8F34B77F4 /* Pods_NotificationServiceExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F682EA52D3CECA56F5B31766 /* Pods_NotificationServiceExtension.framework */; };
3006373429A1011F00D63963 /* Env.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3006373329A1011F00D63963 /* Env.swift */; };
3006373529A1011F00D63963 /* Env.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3006373329A1011F00D63963 /* Env.swift */; };
302D7E2C295BEC44005CBB29 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 302D7E2B295BEC44005CBB29 /* GoogleService-Info.plist */; };
302D7E34295BEE78005CBB29 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302D7E33295BEE78005CBB29 /* NotificationService.swift */; };
302D7E38295BEE78005CBB29 /* NotificationServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 302D7E31295BEE78005CBB29 /* NotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
Expand Down Expand Up @@ -61,11 +61,11 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3006373329A1011F00D63963 /* Env.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Env.swift; sourceTree = "<group>"; };
30095F29295BC58F00D3389F /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
302D7E2B295BEC44005CBB29 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
302D7E31295BEE78005CBB29 /* NotificationServiceExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
302D7E33295BEE78005CBB29 /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
302D7E35295BEE78005CBB29 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
6615E32455EADFC1FBDD78CC /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
78A3A48B351662F042A03F84 /* Pods-NotificationServiceExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationServiceExtension.release.xcconfig"; path = "Target Support Files/Pods-NotificationServiceExtension/Pods-NotificationServiceExtension.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -149,6 +149,7 @@
97C146EF1CF9000F007C117D /* Products */,
3E9C772F68D2059B32B4A97E /* Pods */,
B5A766D2ED4D4067A36F2D1D /* Frameworks */,
6615E32455EADFC1FBDD78CC /* GoogleService-Info.plist */,
);
sourceTree = "<group>";
};
Expand All @@ -164,7 +165,6 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
302D7E2B295BEC44005CBB29 /* GoogleService-Info.plist */,
30095F29295BC58F00D3389F /* Runner.entitlements */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
Expand Down Expand Up @@ -285,9 +285,9 @@
files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
302D7E2C295BEC44005CBB29 /* GoogleService-Info.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
0888D1012BEC428D66F8D1ED /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
43 changes: 8 additions & 35 deletions apps/amiapp_flutter/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ import FirebaseCore
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

FirebaseApp.configure()
// Depending on the method you choose to install Firebase in your app,
// you may need to add functions to this file, such as the following:
// FirebaseApp.configure()
//
// Be sure to read the official Firebase docs to correctly install Firebase in your app.

Messaging.messaging().delegate = self

CustomerIO.initialize(siteId: Env.siteId, apiKey: Env.apiKey, region: .US) { config in
config.autoTrackDeviceAttributes = true
config.logLevel = .debug
}

// Set FCM messaging delegate
Messaging.messaging().delegate = self

let center = UNUserNotificationCenter.current()
center.delegate = self

// Register for push notification
UIApplication.shared.registerForRemoteNotifications()
MessagingPushFCM.initialize(configOptions: nil)

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
Expand All @@ -40,31 +38,6 @@ import FirebaseCore
override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
}

override func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
let handled = MessagingPush.shared.userNotificationCenter(center, didReceive: response,
withCompletionHandler: completionHandler)

// If the Customer.io SDK does not handle the push, it's up to you to handle it and call the
// completion handler. If the SDK did handle it, it called the completion handler for you.
if !handled {
completionHandler()
}
}

// OPTIONAL: If you want your push UI to show even with the app in the foreground, override this function and call
// the completion handler.
override func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
completionHandler([.alert, .badge, .sound])
}
}

extension AppDelegate: MessagingDelegate {
Expand Down
7 changes: 7 additions & 0 deletions apps/amiapp_flutter/ios/firebase_app_id_file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"file_generated_by": "FlutterFire CLI",
"purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
"GOOGLE_APP_ID": "1:1001564516023:ios:6688d08503fde0491a2732",
"FIREBASE_PROJECT_ID": "remote-habits",
"GCM_SENDER_ID": "1001564516023"
}
Loading

0 comments on commit 9967675

Please sign in to comment.