From 02ae5012604b7511ced166c3b7cdc42f7be0a8dd Mon Sep 17 00:00:00 2001 From: Alan Charles Date: Wed, 9 Aug 2023 11:43:15 -0600 Subject: [PATCH] fix: change open_url logic to open browser --- .../BasicExample.xcodeproj/project.pbxproj | 4 ++ .../xcshareddata/swiftpm/Package.resolved | 60 ++++++++++--------- .../BasicExample/AppDelegate.swift | 15 ++++- .../BasicExample/BasicExample.entitlements | 4 ++ ...ageExampleNotificationService.entitlements | 10 ++++ 5 files changed, 62 insertions(+), 31 deletions(-) create mode 100644 Example/BasicExample/TwiliEngageExampleNotificationService/TwiliEngageExampleNotificationService.entitlements diff --git a/Example/BasicExample/BasicExample.xcodeproj/project.pbxproj b/Example/BasicExample/BasicExample.xcodeproj/project.pbxproj index 8451387..7158299 100644 --- a/Example/BasicExample/BasicExample.xcodeproj/project.pbxproj +++ b/Example/BasicExample/BasicExample.xcodeproj/project.pbxproj @@ -57,6 +57,7 @@ 82D179F82A8166A700318017 /* TwiliEngageExampleNotificationService.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = TwiliEngageExampleNotificationService.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 82D179FA2A8166A700318017 /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = ""; }; 82D179FC2A8166A700318017 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 82D209802A840559005118D1 /* TwiliEngageExampleNotificationService.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TwiliEngageExampleNotificationService.entitlements; sourceTree = ""; }; 82F9C4722A8177A200E580E3 /* DeepLinkViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeepLinkViewController.swift; sourceTree = ""; }; 9BC924352A5C9AE20003637C /* BasicExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = BasicExample.entitlements; sourceTree = ""; }; 9BC924362A5C9B4E0003637C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; @@ -159,6 +160,7 @@ 82D179F92A8166A700318017 /* TwiliEngageExampleNotificationService */ = { isa = PBXGroup; children = ( + 82D209802A840559005118D1 /* TwiliEngageExampleNotificationService.entitlements */, 82D179FA2A8166A700318017 /* NotificationService.swift */, 82D179FC2A8166A700318017 /* Info.plist */, ); @@ -511,6 +513,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_ENTITLEMENTS = TwiliEngageExampleNotificationService/TwiliEngageExampleNotificationService.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = V8R4668S2H; @@ -538,6 +541,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_ENTITLEMENTS = TwiliEngageExampleNotificationService/TwiliEngageExampleNotificationService.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = V8R4668S2H; diff --git a/Example/BasicExample/BasicExample.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/BasicExample/BasicExample.xcworkspace/xcshareddata/swiftpm/Package.resolved index 5913212..d41a21c 100644 --- a/Example/BasicExample/BasicExample.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Example/BasicExample/BasicExample.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,32 +1,34 @@ { - "pins" : [ - { - "identity" : "analytics-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/segmentio/analytics-swift", - "state" : { - "branch" : "main", - "revision" : "c8fd5fdf59299f00b3e4303a1b12a6d88893bf56" + "object": { + "pins": [ + { + "package": "Segment", + "repositoryURL": "https://github.com/segmentio/analytics-swift", + "state": { + "branch": "main", + "revision": "b8fe168e2210779c70732f6505913644f6883d48", + "version": null + } + }, + { + "package": "ProgressWebViewController", + "repositoryURL": "https://github.com/kf99916/ProgressWebViewController.git", + "state": { + "branch": null, + "revision": "5b0999f1bca15b2192413e244610d3b5e63192ff", + "version": "3.0.0" + } + }, + { + "package": "Sovran", + "repositoryURL": "https://github.com/segmentio/Sovran-Swift.git", + "state": { + "branch": null, + "revision": "64f3b5150c282a34af4578188dce2fd597e600e3", + "version": "1.1.0" + } } - }, - { - "identity" : "progresswebviewcontroller", - "kind" : "remoteSourceControl", - "location" : "https://github.com/kf99916/ProgressWebViewController.git", - "state" : { - "revision" : "5b0999f1bca15b2192413e244610d3b5e63192ff", - "version" : "3.0.0" - } - }, - { - "identity" : "sovran-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/segmentio/Sovran-Swift.git", - "state" : { - "revision" : "64f3b5150c282a34af4578188dce2fd597e600e3", - "version" : "1.1.0" - } - } - ], - "version" : 2 + ] + }, + "version": 1 } diff --git a/Example/BasicExample/BasicExample/AppDelegate.swift b/Example/BasicExample/BasicExample/AppDelegate.swift index 7dd22c2..89cf7d1 100644 --- a/Example/BasicExample/BasicExample/AppDelegate.swift +++ b/Example/BasicExample/BasicExample/AppDelegate.swift @@ -83,6 +83,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD handleNotificiation(notification: userInfo, shouldAsk: false) } + func applicationWillEnterForeground(_ application: UIApplication) { + + UserDefaults(suiteName: "group.com.segment.twiliopush")?.set(1, forKey: "count"); UIApplication.shared.applicationIconBadgeNumber = 0 + + } + // MARK: UISceneSession Lifecycle func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { @@ -176,7 +182,13 @@ extension AppDelegate { if let tapAction = aps["category"] as? String { switch tapAction { case "open_url": - openWebview(notification: notification, shouldAsk: shouldAsk) + // open link in default browser + if let urlString = notification["link"] as? String { + guard let url = URL(string: urlString) else {return} + UIApplication.shared.open(url, options: [:], completionHandler: nil) + } + // alternatively, open a webview inside of your app + // openWebview(notification: notification, shouldAsk: shouldAsk) case "deep_link": openDeepLinkViewController(notification: notification, shouldAsk: shouldAsk) default: @@ -184,7 +196,6 @@ extension AppDelegate { } } } - } } diff --git a/Example/BasicExample/BasicExample/BasicExample.entitlements b/Example/BasicExample/BasicExample/BasicExample.entitlements index 903def2..478722f 100644 --- a/Example/BasicExample/BasicExample/BasicExample.entitlements +++ b/Example/BasicExample/BasicExample/BasicExample.entitlements @@ -4,5 +4,9 @@ aps-environment development + com.apple.security.application-groups + + group.com.segment.twiliopush + diff --git a/Example/BasicExample/TwiliEngageExampleNotificationService/TwiliEngageExampleNotificationService.entitlements b/Example/BasicExample/TwiliEngageExampleNotificationService/TwiliEngageExampleNotificationService.entitlements new file mode 100644 index 0000000..44877d9 --- /dev/null +++ b/Example/BasicExample/TwiliEngageExampleNotificationService/TwiliEngageExampleNotificationService.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.com.segment.twiliopush + + +