Bad tag blocking further usage

I’ve got a couple of android devices that were using an older version of the plugin (SDK v1.11 I believe) and somehow got some tags stuck.  I’m now using v1.13.1 but for these devices I’m getting an exception when using SendTags or DeleteTags:

06-22 11:58:34.851 19660 19684 W System.err: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number

06-22 11:58:34.851 19660 19684 W System.err: at com.onesignal.OneSignalStateSynchronizer.generateJsonDiff(OneSignalStateSynchronizer.java:97)

06-22 11:58:34.851 19660 19684 W System.err: at com.onesignal.OneSignalStateSynchronizer.generateJsonDiff(OneSignalStateSynchronizer.java:83)

06-22 11:58:34.851 19660 19684 W System.err: at com.onesignal.OneSignalStateSynchronizer.sendTags(OneSignalStateSynchronizer.java:599)

06-22 11:58:34.851 19660 19684 W System.err: at com.onesignal.OneSignal.sendTags(OneSignal.java:714)

06-22 11:58:34.851 19660 19684 W System.err: at OneSignal.LuaLoader$SendTagsFunction.invoke(LuaLoader.java:185)

06-22 11:58:34.851 19660 19684 W System.err: at com.ansca.corona.JavaToNativeShim.nativeRender(Native Method)

06-22 11:58:34.851 19660 19684 W System.err: at com.ansca.corona.JavaToNativeShim.render(JavaToNativeShim.java:182)

06-22 11:58:34.851 19660 19684 W System.err: at com.ansca.corona.Controller.updateRuntimeState(Controller.java:333)

06-22 11:58:34.851 19660 19684 W System.err: at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:421)

06-22 11:58:34.851 19660 19684 W System.err: at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1623)

06-22 11:58:34.851 19660 19684 W System.err: at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1378)

 

I’ve verified that the keys/values I’m sending are correct.   In one devices I went into the OneSignal console and just deleted it completed in an effort to reset things.

 

Is there any way to find these specific devices out of the tens of thousands that I have?  Is there a client side fix (either in lua or your plugin) that can purge these bad items?

 

The one device that I deleted in the console was 9fc79c89-7b19-43a1-bc2e-4a30630e63bb. Some others that I’ve left alone are:

 

d38c89cd-1570-4f21-b699-603d3d32c130

5139d7bc-713d-11e5-b57c-7725cd1b928e

b4955414-67db-11e5-b487-8b855506fdab

 

 

I believe the following Java code should fix your issue however I haven’t test it.

final SharedPreferences prefs = getSharedPreferences(OneSignal.class.getSimpleName(), Context.MODE\_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.remove("ONESIGNAL\_USERSTATE\_SYNCVALYES\_CURRENT\_STATE"); editor.remove("ONESIGNAL\_USERSTATE\_DEPENDVALYES\_CURRENT\_STATE"); editor.remove("ONESIGNAL\_USERSTATE\_SYNCVALYES\_TOSYNC\_STATE"); editor.remove("ONESIGNAL\_USERSTATE\_DEPENDVALYES\_TOSYNC\_STATE"); editor.commit();

You will only need to run it once to clear any bad cached values.

Thanks.   Where should I be putting this code?  In the onLoaded()or in onStarted() of CoronaApplication.java?

I would put it in the onLoaded. Make sure to only run it once so it doesn’t break future caching and create extra network calls.

Well.  So much for not testing your solution.  I ran it once in the onLoaded() method.  Now I get the following exception at app startup:

06-23 08:47:03.881 26960 27205 W System.err: org.json.JSONException: No value for userSubscribePref

06-23 08:47:03.881 26960 27205 W System.err: at org.json.JSONObject.get(JSONObject.java:389)

06-23 08:47:03.881 26960 27205 W System.err: at org.json.JSONObject.getBoolean(JSONObject.java:410)

06-23 08:47:03.881 26960 27205 W System.err: at com.onesignal.OneSignalStateSynchronizer$UserState.getNotificationTypes(OneSignalStateSynchronizer.java:237)

06-23 08:47:03.881 26960 27205 W System.err: at com.onesignal.OneSignalStateSynchronizer$UserState.access$1500(OneSignalStateSynchronizer.java:197)

06-23 08:47:03.881 26960 27205 W System.err: at com.onesignal.OneSignalStateSynchronizer.getSubscribed(OneSignalStateSynchronizer.java:642)

06-23 08:47:03.881 26960 27205 W System.err: at com.onesignal.OneSignal.internalFireIdsAvailableCallback(OneSignal.java:846)

06-23 08:47:03.881 26960 27205 W System.err: at com.onesignal.OneSignal.idsAvailable(OneSignal.java:827)

06-23 08:47:03.881 26960 27205 W System.err: at OneSignal.LuaLoader$IdsAvailableFunction.invoke(LuaLoader.java:293)

06-23 08:47:03.881 26960 27205 W System.err: at com.naef.jnlua.LuaState.lua_pcall(Native Method)

06-23 08:47:03.881 26960 27205 W System.err: at com.naef.jnlua.LuaState.call(Unknown Source)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:138)

06-23 08:47:03.881 26960 27205 W System.err: at network.NetworkRequest$LuaCallback$1.executeUsing(NetworkRequest.java:607)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:170)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:91)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.Controller.updateRuntimeState(Controller.java:305)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:421)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1623)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1378)

06-23 08:47:03.881 26960 27205 E OneSignalSDK: OneSignal UserId: d3289812-3c74-4d66-b555-ef7073e26d9a

Just updated the code in my answer and did a quick test. It should fix the problem above as well.

Thank for the update – that works.

I believe the following Java code should fix your issue however I haven’t test it.

final SharedPreferences prefs = getSharedPreferences(OneSignal.class.getSimpleName(), Context.MODE\_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.remove("ONESIGNAL\_USERSTATE\_SYNCVALYES\_CURRENT\_STATE"); editor.remove("ONESIGNAL\_USERSTATE\_DEPENDVALYES\_CURRENT\_STATE"); editor.remove("ONESIGNAL\_USERSTATE\_SYNCVALYES\_TOSYNC\_STATE"); editor.remove("ONESIGNAL\_USERSTATE\_DEPENDVALYES\_TOSYNC\_STATE"); editor.commit();

You will only need to run it once to clear any bad cached values.

Thanks.   Where should I be putting this code?  In the onLoaded()or in onStarted() of CoronaApplication.java?

I would put it in the onLoaded. Make sure to only run it once so it doesn’t break future caching and create extra network calls.

Well.  So much for not testing your solution.  I ran it once in the onLoaded() method.  Now I get the following exception at app startup:

06-23 08:47:03.881 26960 27205 W System.err: org.json.JSONException: No value for userSubscribePref

06-23 08:47:03.881 26960 27205 W System.err: at org.json.JSONObject.get(JSONObject.java:389)

06-23 08:47:03.881 26960 27205 W System.err: at org.json.JSONObject.getBoolean(JSONObject.java:410)

06-23 08:47:03.881 26960 27205 W System.err: at com.onesignal.OneSignalStateSynchronizer$UserState.getNotificationTypes(OneSignalStateSynchronizer.java:237)

06-23 08:47:03.881 26960 27205 W System.err: at com.onesignal.OneSignalStateSynchronizer$UserState.access$1500(OneSignalStateSynchronizer.java:197)

06-23 08:47:03.881 26960 27205 W System.err: at com.onesignal.OneSignalStateSynchronizer.getSubscribed(OneSignalStateSynchronizer.java:642)

06-23 08:47:03.881 26960 27205 W System.err: at com.onesignal.OneSignal.internalFireIdsAvailableCallback(OneSignal.java:846)

06-23 08:47:03.881 26960 27205 W System.err: at com.onesignal.OneSignal.idsAvailable(OneSignal.java:827)

06-23 08:47:03.881 26960 27205 W System.err: at OneSignal.LuaLoader$IdsAvailableFunction.invoke(LuaLoader.java:293)

06-23 08:47:03.881 26960 27205 W System.err: at com.naef.jnlua.LuaState.lua_pcall(Native Method)

06-23 08:47:03.881 26960 27205 W System.err: at com.naef.jnlua.LuaState.call(Unknown Source)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:138)

06-23 08:47:03.881 26960 27205 W System.err: at network.NetworkRequest$LuaCallback$1.executeUsing(NetworkRequest.java:607)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:170)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:91)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.Controller.updateRuntimeState(Controller.java:305)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:421)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1623)

06-23 08:47:03.881 26960 27205 W System.err: at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1378)

06-23 08:47:03.881 26960 27205 E OneSignalSDK: OneSignal UserId: d3289812-3c74-4d66-b555-ef7073e26d9a

Just updated the code in my answer and did a quick test. It should fix the problem above as well.

Thank for the update – that works.