-
Notifications
You must be signed in to change notification settings - Fork 39
[MOB-9064] JWT #740
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
Draft
Parent:
[SDK-82] New Architecture
lposen
wants to merge
110
commits into
new-arch/master
Choose a base branch
from
jwt/master
base: new-arch/master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[MOB-9064] JWT #740
+3,858
−547
Conversation
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
… RNIterableAPIModule
…AppMessage.getMessageId()
…sses' into jwt/MOB-10947-task-3-android-retrypolicy-config-at-android-br
…in Iterable class
…sses' into jwt/MOB-10947-task-3-android-retrypolicy-config-at-android-br
…sses' into jwt/MOB-10947-task-3-android-retrypolicy-config-at-android-br
…reReason enum values
…sses' into jwt/MOB-10947-task-3-android-retrypolicy-config-at-android-br
…line configuration
…sses' into jwt/MOB-10947-task-3-android-retrypolicy-config-at-android-br
…gistration in AppDelegate
…n ReactIterableAPI
…terableAppProvider
…ation in React Native
…andling in IterableAppProvider
…o clean up the implementation
…in IterableAppProvider
…ove old utility index
…ator [SDK-136] Add Jwt Generator to Example app
example/android/app/src/main/java/iterable/reactnativesdk/example/IterableJwtGenerator.java
Show resolved
Hide resolved
example/android/app/src/main/java/iterable/reactnativesdk/example/JwtTokenModule.kt
Show resolved
Hide resolved
example/android/app/src/main/java/iterable/reactnativesdk/example/IterableJwtGenerator.java
Show resolved
Hide resolved
example/android/app/src/main/java/iterable/reactnativesdk/example/JwtTokenModule.kt
Show resolved
Hide resolved
Comment on lines
+77
to
+104
| public static String generateToken( | ||
| String secret, Duration duration, String email, String userId) { | ||
|
|
||
| if (duration.compareTo(maxTokenLifetime) > 0) | ||
| throw new IllegalArgumentException( | ||
| "Duration must be one year or less." | ||
| ); | ||
|
|
||
| if ((userId != null && email != null) || (userId == null && email == null)) | ||
| throw new IllegalArgumentException( | ||
| "The token must include a userId or email, but not both." | ||
| ); | ||
|
|
||
| long now = millisToSeconds(System.currentTimeMillis()); | ||
|
|
||
| String payload; | ||
| if (userId != null) | ||
| payload = String.format( | ||
| "{ \"userId\": \"%s\", \"iat\": %d, \"exp\": %d }", | ||
| userId, now, now + millisToSeconds(duration.toMillis()) | ||
| ); | ||
| else | ||
| payload = String.format( | ||
| "{ \"email\": \"%s\", \"iat\": %d, \"exp\": %d }", | ||
| email, now, now + millisToSeconds(duration.toMillis()) | ||
| ); | ||
|
|
||
| return generateToken(secret, payload); |
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.
Comment on lines
+17
to
+22
| fun generateJwtToken( | ||
| secret: String, | ||
| durationMs: Double, | ||
| email: String?, | ||
| userId: String?, | ||
| promise: Promise |
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.
Comment on lines
+79
to
+101
| 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() | ||
| } | ||
| } | ||
| } |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🔹 JIRA Ticket(s) if any
✏️ Description
Add JWT functionality to sdk
This contains the following PRs:
This solves the following client issues: