Skip to content

Commit

Permalink
refactor: uikit sample universal links in push open app, not browser (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
levibostian committed May 23, 2023
1 parent 5fd0144 commit 1816640
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 15 additions & 1 deletion Apps/APN-UIKit/APN UIKit/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var storage = DIGraph.shared.storage
var deepLinkHandler = DIGraph.shared.deepLinksHandlerUtil

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
Expand All @@ -21,7 +22,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

func initializeCioAndInAppListeners() {
// Initialise CustomerIO SDK
// Initialize CustomerIO SDK

CustomerIO.initialize(siteId: BuildEnvironment.CustomerIO.siteId, apiKey: BuildEnvironment.CustomerIO.apiKey, region: .US) { config in
config.logLevel = self.storage.isDebugModeEnabled ?? false ? .debug : .none
Expand All @@ -38,6 +39,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
MessagingInApp.initialize(eventListener: self)
}

// Handle Universal Link deep link from the Customer.io SDK. This function will get called if a push notification
// gets clicked that has a Universal Link deep link attached and the app is in the foreground. Otherwise, another function
// in your app may get called depending on what technology you use (Scenes, UIKit, Swift UI).
//
// Learn more: https://customer.io/docs/sdk/ios/push/#universal-links-deep-links
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
guard let universalLinkUrl = userActivity.webpageURL else {
return false
}

return deepLinkHandler.handleUniversalLinkDeepLink(universalLinkUrl)
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
Expand Down
4 changes: 3 additions & 1 deletion Apps/APN-UIKit/APN UIKit/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}
}

// Universal Links
// Universal Links - handling universal links that come into the mobile app, not from the Customer.io SDK.
// To handle Universal Links from the Customer.io SDK, see `AppDelegate` file for implementation.
// Learn more: https://customer.io/docs/sdk/ios/push/#universal-links-deep-links
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
guard let universalLinkUrl = userActivity.webpageURL else {
return
Expand Down

0 comments on commit 1816640

Please sign in to comment.