Skip to content

Commit

Permalink
fix: change open_url logic to open browser
Browse files Browse the repository at this point in the history
  • Loading branch information
alanjcharles committed Aug 9, 2023
1 parent 8c51abe commit 02ae501
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 31 deletions.
4 changes: 4 additions & 0 deletions Example/BasicExample/BasicExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<group>"; };
82D179FC2A8166A700318017 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
82D209802A840559005118D1 /* TwiliEngageExampleNotificationService.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TwiliEngageExampleNotificationService.entitlements; sourceTree = "<group>"; };
82F9C4722A8177A200E580E3 /* DeepLinkViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeepLinkViewController.swift; sourceTree = "<group>"; };
9BC924352A5C9AE20003637C /* BasicExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = BasicExample.entitlements; sourceTree = "<group>"; };
9BC924362A5C9B4E0003637C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -159,6 +160,7 @@
82D179F92A8166A700318017 /* TwiliEngageExampleNotificationService */ = {
isa = PBXGroup;
children = (
82D209802A840559005118D1 /* TwiliEngageExampleNotificationService.entitlements */,
82D179FA2A8166A700318017 /* NotificationService.swift */,
82D179FC2A8166A700318017 /* Info.plist */,
);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 13 additions & 2 deletions Example/BasicExample/BasicExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -176,15 +182,20 @@ 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:
return
}
}
}

}
}

4 changes: 4 additions & 0 deletions Example/BasicExample/BasicExample/BasicExample.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.segment.twiliopush</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.segment.twiliopush</string>
</array>
</dict>
</plist>

0 comments on commit 02ae501

Please sign in to comment.