Skip to content

Commit 1b9491f

Browse files
committed
fixup: identity verification improvement
1 parent db78c39 commit 1b9491f

35 files changed

+174
-296
lines changed

Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/application/MainApplication.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void onCreate() {
6666
// This will reproduce result similar to Kotlin CouroutineScope.launch{}, which may potentially crash the app
6767
ExecutorService executor = Executors.newSingleThreadExecutor();
6868
@SuppressLint({"NewApi", "LocalSuppress"}) CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
69-
//OneSignal.getNotifications().requestPermission(true, Continue.none());
69+
OneSignal.getNotifications().requestPermission(true, Continue.none());
7070
}, executor);
7171
future.join(); // Waits for the task to complete
7272
executor.shutdown();
@@ -144,9 +144,6 @@ public void onUserStateChange(@NonNull UserChangedState state) {
144144
OneSignal.addUserJwtInvalidatedListner(new IUserJwtInvalidatedListener() {
145145
@Override
146146
public void onUserJwtInvalidated(@NonNull UserJwtInvalidatedEvent event) {
147-
// !!! For manual testing only
148-
String jwt = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIwMTM5YmQ2Zi00NTFmLTQzOGMtODg4Ni00ZTBmMGZlM2EwODUiLCJleHAiOjE3MjczNjkyMjIsImlkZW50aXR5Ijp7ImV4dGVybmFsX2lkIjoiamluIn0sInN1YnNjcmlwdGlvbnMiOlt7InR5cGUiOiJFbWFpbCIsInRva2VuIjoidGVzdEBkb21haW4uY29tIn0seyJ0eXBlIjoiU01TIiwidG9rZW4iOiIrMTIzNDU2NzgifSx7InR5cGUiOiJBbmRyb2lkUHVzaCIsImlkIjoiMTIzZTQ1NjctZTg5Yi0xMmQzLWE0NTYtNDI2NjE0MTc0MDAwIn1dfQ.6XF7wRF4lLOvKr5Gd3MHv9j7U151hcBjmqSyk6nI6JVYUgt6q0YRp2j1aSJcg8VmaejzP1DouN1DpWUT_JTRXA";
149-
OneSignal.updateUserJwt(event.getExternalId(), jwt);
150147
Log.v(Tag.LOG_TAG, "onUserJwtInvalidated fired with ID:" + event.getExternalId());
151148
}
152149
});

Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/model/MainActivityViewModel.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,7 @@ private void setupAppLayout() {
411411
@Override
412412
public void onSuccess(String update) {
413413
if (update != null && !update.isEmpty()) {
414-
String jwt = "InitialJWT";
415-
OneSignal.login(update, jwt);
414+
OneSignal.login(update);
416415
refreshState();
417416
}
418417
}
@@ -450,8 +449,6 @@ private void setupJWTLayout() {
450449
public void onSuccess(String update) {
451450
if (update != null && !update.isEmpty()) {
452451
OneSignal.updateUserJwt(OneSignal.getUser().getExternalId(), update);
453-
//String jwt = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxNjg4ZDhmMi1kYTdmLTQ4MTUtOGVlMy05ZDEzNzg4NDgyYzgiLCJpYXQiOjE3MTQwODA4MTMsImlkZW50aXR5Ijp7ImV4dGVybmFsX2lkIjoiMjAyNDA0MjUtYWxleDQyIn0sInN1YnNjcmlwdGlvbiI6W3sidHlwZSI6IiIsImlkIjoiMmRlZGU3MzItMTEyNi00MTlkLTk5M2UtNDIzYWQyYTZiZGU5In1dfQ.rzZ-HaDm1EwxbMxd8937bWzPhPSQDDSqSzaASgZZc5A5v8g6ZQHizN9CljOmoQ4lTLm7noD6rOmR07tlZdrI5w";
454-
//OneSignal.login(update, jwt);
455452
refreshState();
456453
}
457454
}

Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/util/SharedPreferenceUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static boolean exists(Context context, String key) {
2424
}
2525

2626
public static String getOneSignalAppId(Context context) {
27-
return getSharedPreference(context).getString(OS_APP_ID_SHARED_PREF, "0139bd6f-451f-438c-8886-4e0f0fe3a085");
27+
return getSharedPreference(context).getString(OS_APP_ID_SHARED_PREF, "77e32082-ea27-42e3-a898-c72e141824ef");
2828
}
2929

3030
public static boolean getUserPrivacyConsent(Context context) {

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ interface IOneSignal {
1919
*/
2020
val isInitialized: Boolean
2121

22-
/**
23-
* Whether the security feature to authenticate your external user ids is enabled
24-
*/
25-
val useIdentityVerification: Boolean
26-
2722
/**
2823
* The user manager for accessing user-scoped
2924
* management.

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IUserJwtInvalidatedListener.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.onesignal
22

3-
/** TODO: complete the comment part for this listener
3+
/**
44
* Implement this interface and provide an instance to [OneSignal.addUserJwtInvalidatedListner]
55
* in order to receive control when the JWT for the current user is invalidated.
66
*
7-
* @see [User JWT Invalidated Event | OneSignal Docs](https://documentation.onesignal.com/docs/)
7+
* @see [User JWT Invalidated Event | OneSignal Docs](https://documentation.onesignal.com/docs/identity-verification)
88
*/
99
interface IUserJwtInvalidatedListener {
1010
/**

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/OneSignal.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ object OneSignal {
2929
val isInitialized: Boolean
3030
get() = oneSignal.isInitialized
3131

32-
/**
33-
* Whether the security feature to authenticate your external user ids is enabled
34-
*/
35-
@JvmStatic
36-
val useIdentityVerification: Boolean
37-
get() = oneSignal.useIdentityVerification
38-
3932
/**
4033
* The current SDK version as a string.
4134
*/

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/UserJwtInvalidatedEvent.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package com.onesignal
22

3-
/** TODO: jwt documentation
3+
/**
44
* The event passed into [IUserJwtInvalidatedListener.onUserJwtInvalidated], it provides access
55
* to the external ID whose JWT has just been invalidated.
66
*
7+
* For more information https://documentation.onesignal.com/docs/identity-verification#4-handle-jwt-lifecycle-events
78
*/
89
class UserJwtInvalidatedEvent(
910
val externalId: String,

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/http/impl/HttpClient.kt

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,29 @@ internal class HttpClient(
4646
url: String,
4747
body: JSONObject,
4848
headers: OptionalHeaders?,
49-
): HttpResponse {
50-
return makeRequest(url, "POST", body, _configModelStore.model.httpTimeout, headers)
51-
}
49+
): HttpResponse = makeRequest(url, "POST", body, _configModelStore.model.httpTimeout, headers)
5250

5351
override suspend fun get(
5452
url: String,
5553
headers: OptionalHeaders?,
56-
): HttpResponse {
57-
return makeRequest(url, null, null, _configModelStore.model.httpGetTimeout, headers)
58-
}
54+
): HttpResponse = makeRequest(url, null, null, _configModelStore.model.httpGetTimeout, headers)
5955

6056
override suspend fun put(
6157
url: String,
6258
body: JSONObject,
6359
headers: OptionalHeaders?,
64-
): HttpResponse {
65-
return makeRequest(url, "PUT", body, _configModelStore.model.httpTimeout, headers)
66-
}
60+
): HttpResponse = makeRequest(url, "PUT", body, _configModelStore.model.httpTimeout, headers)
6761

6862
override suspend fun patch(
6963
url: String,
7064
body: JSONObject,
7165
headers: OptionalHeaders?,
72-
): HttpResponse {
73-
return makeRequest(url, "PATCH", body, _configModelStore.model.httpTimeout, headers)
74-
}
66+
): HttpResponse = makeRequest(url, "PATCH", body, _configModelStore.model.httpTimeout, headers)
7567

7668
override suspend fun delete(
7769
url: String,
7870
headers: OptionalHeaders?,
79-
): HttpResponse {
80-
return makeRequest(url, "DELETE", null, _configModelStore.model.httpTimeout, headers)
81-
}
71+
): HttpResponse = makeRequest(url, "DELETE", null, _configModelStore.model.httpTimeout, headers)
8272

8373
private suspend fun makeRequest(
8474
url: String,
@@ -151,15 +141,10 @@ internal class HttpClient(
151141
con.setRequestProperty("SDK-Version", "onesignal/android/" + OneSignalUtils.SDK_VERSION)
152142

153143
val jwt = headers?.jwt
154-
if (!jwt.isNullOrEmpty()) {
144+
if (jwt != null) {
155145
con.setRequestProperty("Authorization", "Bearer $jwt")
156146
}
157147

158-
val deviceAuthPushToken = headers?.deviceAuthPushToken
159-
if (_configModelStore.model.useIdentityVerification && !deviceAuthPushToken.isNullOrEmpty()) {
160-
con.setRequestProperty("Device-Auth-Push-Token", "Basic $deviceAuthPushToken")
161-
}
162-
163148
if (OneSignalWrapper.sdkType != null && OneSignalWrapper.sdkVersion != null) {
164149
con.setRequestProperty("SDK-Wrapper", "onesignal/${OneSignalWrapper.sdkType}/${OneSignalWrapper.sdkVersion}")
165150
}

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/http/impl/HttpConnectionFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ internal class HttpConnectionFactory(
1010
) : IHttpConnectionFactory {
1111
@Throws(IOException::class)
1212
override fun newHttpURLConnection(url: String): HttpURLConnection {
13-
return URL("https://staging.onesignal.com/api/v1/" + url).openConnection() as HttpURLConnection
13+
return URL(_configModelStore.model.apiUrl + url).openConnection() as HttpURLConnection
1414
}
1515
}

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/http/impl/OptionalHeaders.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ data class OptionalHeaders(
1818
*/
1919
val sessionDuration: Long? = null,
2020
val jwt: String? = null,
21-
val deviceAuthPushToken: String? = null,
2221
)

0 commit comments

Comments
 (0)