-
Notifications
You must be signed in to change notification settings - Fork 39
[MOB-11032] configure JWT for iOS #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lposen
merged 16 commits into
jwt/master
from
jwt/MOB-11032-task-4-ios-bridge-retrypolicy-and-authfailure
Oct 14, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
38f2791
chore: update Iterable-iOS-SDK dependency to version 6.6.1 in podspec
lposen e36be70
chore: remove tempfix and update Embed Pods Frameworks build phase in…
lposen 356e767
feat: implement user notification handling and remote notification re…
lposen 04cb0d1
feat: add pauseAuthRetries method and enhance auth failure handling i…
lposen 47cdab3
chore: update Xcode project configuration and enable authHandler in I…
lposen b22b9ea
refactor: delegate event sending for auth failure handling in ReactIt…
lposen 16c2c9a
fix: improve JWT error logging and alert messaging for auth failures
lposen 78e4914
Merge branch 'jwt/MOB-10947-task-3-android-retrypolicy-config-at-andr…
lposen edfa70f
refactor: remove unnecessary NSLog statements from AppDelegate.swift
lposen 836ad6c
Merge branch 'jwt/MOB-10947-task-3-android-retrypolicy-config-at-andr…
lposen 20cd031
Merge branch 'jwt/MOB-10947-task-3-android-retrypolicy-config-at-andr…
lposen 3870dc3
Merge branch 'jwt/MOB-10947-task-3-android-retrypolicy-config-at-andr…
lposen d95ae90
fix: standardize authentication failure reason representation across …
lposen 0587649
Merge branch 'jwt/MOB-10947-task-3-android-retrypolicy-config-at-andr…
lposen 70fa36a
feat: implement retry policy configuration in IterableConfig for iOS
lposen db24c40
Merge branch 'jwt/master' into jwt/MOB-11032-task-4-ios-bridge-retryp…
lposen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,13 @@ | |
// Created by Loren Posen on 6/11/25. | ||
// | ||
|
||
import UIKit | ||
import React | ||
import ReactAppDependencyProvider | ||
import React_RCTAppDelegate | ||
import UIKit | ||
import ReactAppDependencyProvider | ||
import UserNotifications | ||
|
||
import IterableSDK | ||
|
||
@main | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
@@ -21,6 +24,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | |
_ application: UIApplication, | ||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil | ||
) -> Bool { | ||
ITBInfo() | ||
|
||
let delegate = ReactNativeDelegate() | ||
let factory = RCTReactNativeFactory(delegate: delegate) | ||
delegate.dependencyProvider = RCTAppDependencyProvider() | ||
|
@@ -36,8 +41,65 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | |
launchOptions: launchOptions | ||
) | ||
|
||
setupUserNotificationCenter() | ||
|
||
return true | ||
} | ||
|
||
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | ||
ITBInfo() | ||
IterableAPI.register(token: deviceToken) | ||
} | ||
|
||
func application(_ application: UIApplication, | ||
didFailToRegisterForRemoteNotificationsWithError | ||
error: Error) { | ||
ITBInfo("error: \(error)") | ||
} | ||
|
||
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { | ||
ITBInfo() | ||
IterableAppIntegration.application(application, didReceiveRemoteNotification: userInfo, fetchCompletionHandler: completionHandler) | ||
} | ||
|
||
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { | ||
ITBInfo() | ||
guard let url = userActivity.webpageURL else { | ||
return false | ||
} | ||
|
||
return IterableAPI.handle(universalLink: url) | ||
} | ||
|
||
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { | ||
ITBInfo() | ||
return RCTLinkingManager.application(app, open: url, options: options) | ||
} | ||
|
||
private func setupUserNotificationCenter() { | ||
UNUserNotificationCenter.current().delegate = self | ||
UNUserNotificationCenter.current().getNotificationSettings { settings in | ||
if settings.authorizationStatus != .authorized { | ||
ITBInfo("Not authorized") | ||
// not authorized, ask for permission | ||
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, _ in | ||
ITBInfo("auth: \(success)") | ||
if success { | ||
DispatchQueue.main.async { | ||
UIApplication.shared.registerForRemoteNotifications() | ||
} | ||
} | ||
// TODO: Handle error etc. | ||
} | ||
} else { | ||
// already authorized | ||
ITBInfo("Already authorized") | ||
DispatchQueue.main.async { | ||
UIApplication.shared.registerForRemoteNotifications() | ||
} | ||
} | ||
} | ||
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+79
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
} | ||
|
||
class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate { | ||
|
@@ -46,10 +108,22 @@ class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate { | |
} | ||
|
||
override func bundleURL() -> URL? { | ||
#if DEBUG | ||
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index") | ||
#else | ||
Bundle.main.url(forResource: "main", withExtension: "jsbundle") | ||
#endif | ||
#if DEBUG | ||
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index") | ||
#else | ||
Bundle.main.url(forResource: "main", withExtension: "jsbundle") | ||
#endif | ||
} | ||
} | ||
|
||
extension AppDelegate: UNUserNotificationCenterDelegate { | ||
// App is running in the foreground | ||
public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { | ||
completionHandler([.alert, .badge, .sound]) | ||
} | ||
|
||
// The method will be called on the delegate when the user responded to the notification by opening the application, dismissing the notification or choosing a UNNotificationAction. The delegate must be set before the application returns from applicationDidFinishLaunching:. | ||
public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { | ||
IterableAppIntegration.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our example app doesn't seem to be correctly configured for universal links, so I was trying to update it to handle things correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can take it out if you'd like