Skip to content

Commit 8c3d45b

Browse files
committed
testflight build
1 parent 4422beb commit 8c3d45b

File tree

5 files changed

+65
-8
lines changed

5 files changed

+65
-8
lines changed

EmbedFramework/AdaWebHost.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public class AdaWebHost: NSObject {
149149
// MARK: - Public Methods
150150

151151
public func setDeviceToken(deviceToken : String) {
152-
let toRun = "adaEmbed.setDeviceToken(\(deviceToken));"
152+
let toRun = "adaEmbed.setDeviceToken(\"\(deviceToken)\");"
153153

154154
self.evalJS(toRun)
155155
}

ExampleAppCocoapod/ExampleAppCocoapod.xcodeproj/project.pbxproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
66B2D16C192F5D92B22AA0AE /* Pods-ExampleAppCocoapod.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleAppCocoapod.release.xcconfig"; path = "Target Support Files/Pods-ExampleAppCocoapod/Pods-ExampleAppCocoapod.release.xcconfig"; sourceTree = "<group>"; };
3131
73D3C79D896FEE077C559153 /* Pods-ExampleAppCocoapod.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleAppCocoapod.debug.xcconfig"; path = "Target Support Files/Pods-ExampleAppCocoapod/Pods-ExampleAppCocoapod.debug.xcconfig"; sourceTree = "<group>"; };
3232
98CB6A2FEE20585E9E84257B /* Pods_ExampleAppCocoapod.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ExampleAppCocoapod.framework; sourceTree = BUILT_PRODUCTS_DIR; };
33+
B7035B65284E4B17007D20FC /* ExampleAppCocoapod.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ExampleAppCocoapod.entitlements; sourceTree = "<group>"; };
3334
/* End PBXFileReference section */
3435

3536
/* Begin PBXFrameworksBuildPhase section */
@@ -65,6 +66,7 @@
6566
039BA90D270E157C00DF3600 /* ExampleAppCocoapod */ = {
6667
isa = PBXGroup;
6768
children = (
69+
B7035B65284E4B17007D20FC /* ExampleAppCocoapod.entitlements */,
6870
039BA928270E16A900DF3600 /* InjectedViewController.swift */,
6971
039BA929270E16A900DF3600 /* Main.storyboard */,
7072
039BA90E270E157C00DF3600 /* AppDelegate.swift */,
@@ -352,9 +354,10 @@
352354
buildSettings = {
353355
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
354356
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
357+
CODE_SIGN_ENTITLEMENTS = ExampleAppCocoapod/ExampleAppCocoapod.entitlements;
355358
CODE_SIGN_STYLE = Automatic;
356359
CURRENT_PROJECT_VERSION = 1;
357-
DEVELOPMENT_TEAM = BY82U3VVS9;
360+
DEVELOPMENT_TEAM = ZRU59KP7YH;
358361
GENERATE_INFOPLIST_FILE = YES;
359362
INFOPLIST_FILE = ExampleAppCocoapod/Info.plist;
360363
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
@@ -367,7 +370,7 @@
367370
"@executable_path/Frameworks",
368371
);
369372
MARKETING_VERSION = 1.0;
370-
PRODUCT_BUNDLE_IDENTIFIER = MichaelTest.ExampleAppCocoapod;
373+
PRODUCT_BUNDLE_IDENTIFIER = support.ada.ios.sample;
371374
PRODUCT_NAME = "$(TARGET_NAME)";
372375
SWIFT_EMIT_LOC_STRINGS = YES;
373376
SWIFT_VERSION = 5.0;
@@ -381,9 +384,10 @@
381384
buildSettings = {
382385
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
383386
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
387+
CODE_SIGN_ENTITLEMENTS = ExampleAppCocoapod/ExampleAppCocoapod.entitlements;
384388
CODE_SIGN_STYLE = Automatic;
385389
CURRENT_PROJECT_VERSION = 1;
386-
DEVELOPMENT_TEAM = BY82U3VVS9;
390+
DEVELOPMENT_TEAM = ZRU59KP7YH;
387391
GENERATE_INFOPLIST_FILE = YES;
388392
INFOPLIST_FILE = ExampleAppCocoapod/Info.plist;
389393
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
@@ -396,7 +400,7 @@
396400
"@executable_path/Frameworks",
397401
);
398402
MARKETING_VERSION = 1.0;
399-
PRODUCT_BUNDLE_IDENTIFIER = MichaelTest.ExampleAppCocoapod;
403+
PRODUCT_BUNDLE_IDENTIFIER = support.ada.ios.sample;
400404
PRODUCT_NAME = "$(TARGET_NAME)";
401405
SWIFT_EMIT_LOC_STRINGS = YES;
402406
SWIFT_VERSION = 5.0;

ExampleAppCocoapod/ExampleAppCocoapod/AppDelegate.swift

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66
//
77

88
import UIKit
9+
import UserNotifications
10+
911

1012
@main
11-
class AppDelegate: UIResponder, UIApplicationDelegate {
13+
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
1214

1315

1416

1517
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1618
// Override point for customization after application launch.
19+
UNUserNotificationCenter.current().delegate = self
20+
registerForPushNotifications()
1721
return true
1822
}
1923

@@ -31,6 +35,42 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3135
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
3236
}
3337

38+
func application(_ application: UIApplication,
39+
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
40+
let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
41+
let token = tokenParts.joined()
42+
print("Device Token: \(token)")
43+
UserDefaults.standard.set(token, forKey: "device_token")
44+
};
45+
46+
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
47+
print(error.localizedDescription)
48+
}
49+
50+
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
51+
completionHandler([.banner, .badge, .sound])
52+
}
53+
54+
55+
func registerForPushNotifications() {
56+
//1
57+
UNUserNotificationCenter.current()
58+
.requestAuthorization(
59+
options: [.alert, .sound, .badge]) { [weak self] granted, _ in
60+
print("Permission granted: \(granted)")
61+
guard granted else { return }
62+
self?.getNotificationSettings()
63+
}
64+
}
65+
66+
func getNotificationSettings() {
67+
UNUserNotificationCenter.current().getNotificationSettings { settings in
68+
print("Notification settings: \(settings)")
69+
guard settings.authorizationStatus == .authorized else { return }
70+
DispatchQueue.main.async {
71+
UIApplication.shared.registerForRemoteNotifications()
72+
}
73+
}
74+
}
3475

3576
}
36-
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
</dict>
8+
</plist>

ExampleAppCocoapod/ExampleAppCocoapod/ViewController.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010
import AdaEmbedFramework
1111

1212
class ViewController: UIViewController {
13-
lazy var adaFramework = AdaWebHost(handle: "nic", appScheme: "adaexampleapp", webViewLoadingErrorCallback: LoadingErrorCallback, webViewTimeout: 30.0)
13+
lazy var adaFramework = AdaWebHost(handle: "messaging-platform-bot", domain: "ada-dev", appScheme: "adaexampleapp", webViewLoadingErrorCallback: LoadingErrorCallback, webViewTimeout: 30.0)
1414

1515
@IBOutlet var firstNameField: UITextField!
1616
@IBOutlet var lastNameField: UITextField!
@@ -40,6 +40,11 @@ class ViewController: UIViewController {
4040
}
4141

4242
@IBAction func openModalSupport(_ sender: UIButton) {
43+
let deviceToken : String? = UserDefaults.standard.string(forKey: "device_token")
44+
45+
if let xy = deviceToken {
46+
adaFramework.setDeviceToken(deviceToken: xy)
47+
}
4348
adaFramework.launchModalWebSupport(from: self)
4449
}
4550

0 commit comments

Comments
 (0)