Skip to content

Commit 7c4484f

Browse files
committed
fixup: identity verification improvement
1 parent ce27689 commit 7c4484f

39 files changed

+224
-343
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/CoreModule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import com.onesignal.core.internal.preferences.IPreferencesService
3131
import com.onesignal.core.internal.preferences.impl.PreferencesService
3232
import com.onesignal.core.internal.purchases.impl.TrackAmazonPurchase
3333
import com.onesignal.core.internal.purchases.impl.TrackGooglePurchase
34+
import com.onesignal.core.internal.startup.IBootstrapService
3435
import com.onesignal.core.internal.startup.IStartableService
3536
import com.onesignal.core.internal.time.ITime
3637
import com.onesignal.core.internal.time.impl.Time
@@ -40,6 +41,7 @@ import com.onesignal.location.ILocationManager
4041
import com.onesignal.location.internal.MisconfiguredLocationManager
4142
import com.onesignal.notifications.INotificationsManager
4243
import com.onesignal.notifications.internal.MisconfiguredNotificationsManager
44+
import com.onesignal.user.internal.service.IdentityVerificationService
4345

4446
internal class CoreModule : IModule {
4547
override fun register(builder: ServiceBuilder) {
@@ -59,6 +61,7 @@ internal class CoreModule : IModule {
5961
builder.register<ConfigModelStore>().provides<ConfigModelStore>()
6062
builder.register<ParamsBackendService>().provides<IParamsBackendService>()
6163
builder.register<ConfigModelStoreListener>().provides<IStartableService>()
64+
builder.register<IdentityVerificationService>().provides<IBootstrapService>()
6265

6366
// Operations
6467
builder.register<OperationModelStore>().provides<OperationModelStore>()

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/config/ConfigModel.kt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.onesignal.core.internal.config
22

3-
import com.onesignal.common.events.EventProducer
43
import com.onesignal.common.modeling.Model
5-
import com.onesignal.core.internal.backend.ParamsObject
64
import org.json.JSONArray
75
import org.json.JSONObject
86

@@ -321,20 +319,6 @@ class ConfigModel : Model() {
321319

322320
return null
323321
}
324-
325-
var fetchParamsNotifier = EventProducer<FetchParamsObserver>()
326-
327-
fun addFetchParamsObserver(observer: FetchParamsObserver) {
328-
fetchParamsNotifier.subscribe(observer)
329-
}
330-
331-
fun removeFetchParamsObserver(observer: FetchParamsObserver) {
332-
fetchParamsNotifier.unsubscribe(observer)
333-
}
334-
335-
fun notifyFetchParams(params: ParamsObject) {
336-
fetchParamsNotifier.fire { it.onParamsFetched(params) }
337-
}
338322
}
339323

340324
/**
@@ -441,7 +425,3 @@ class FCMConfigModel(parentModel: Model, parentProperty: String) : Model(parentM
441425
setOptStringProperty(::apiKey.name, value)
442426
}
443427
}
444-
445-
interface FetchParamsObserver {
446-
fun onParamsFetched(params: ParamsObject)
447-
}

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/config/impl/ConfigModelStoreListener.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ internal class ConfigModelStoreListener(
7272
// copy current model into new model, then override with what comes down.
7373
val config = ConfigModel()
7474
config.initializeFromModel(null, _configModelStore.model)
75-
config.fetchParamsNotifier = _configModelStore.model.fetchParamsNotifier
7675
config.isInitializedWithRemote = true
7776

7877
// these are always copied from the backend params
@@ -105,7 +104,6 @@ internal class ConfigModelStoreListener(
105104

106105
_configModelStore.replace(config, ModelChangeTags.HYDRATE)
107106
success = true
108-
config.notifyFetchParams(params)
109107
} catch (ex: BackendException) {
110108
if (ex.statusCode == HttpURLConnection.HTTP_FORBIDDEN) {
111109
Logging.fatal("403 error getting OneSignal params, omitting further retries!")

0 commit comments

Comments
 (0)