Bug with GetTags on Android

I’ve communicated all the details to OneSignal, but I thought I’d drop this here as well to see if this is impacting anyone else.

The TLDR is that once a GetTags() call is made the following two errors will show up in the logs:

D/OneSignal: OneSignalRestClient: Making request to: https://onesignal.com/api/v1/players/xxxxx-xxxxx-xxxxx-xxxxx/on\_session D/OneSignal: OneSignalRestClient: POST SEND JSON: {"tags":{"build\_number":"1001"},"app\_id":"xxxxx-xxxxx-xxxxx-xxxxx"} V/OneSignal: OneSignalRestClient: After con.getResponseCode  to: https://onesignal.com/api/v1/players/xxxxx-xxxxx-xxxxx-xxxxx/on\_session D/OneSignal: OneSignalRestClient: Successfully finished request to: https://onesignal.com/api/v1/players/xxxxx-xxxxx-xxxxx-xxxxx/on\_session D/OneSignal: POST RECEIVED JSON: {"success":true,"id":"xxxxx-xxxxx-xxxxx-xxxxx"} I/OneSignal: Device registered, UserId = xxxxx-xxxxx-xxxxx-xxxxx W/System.err: com.naef.jnlua.LuaRuntimeException: attempt to call a nil value W/System.err:     at com.naef.jnlua.LuaState.lua\_pcall(Native Method) W/System.err:     at com.naef.jnlua.LuaState.call(Unknown Source:4) W/System.err:     at OneSignal.LuaLoader$GetTagsFunction$CoronaGetTagsHandler$1$1.executeUsing(LuaLoader.java:263) W/System.err:     at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:195) W/System.err:     at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:116) W/System.err:     at com.ansca.corona.Controller.updateRuntimeState(Controller.java:343) W/System.err:     at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:450) W/System.err:     at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1625) W/System.err:     at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1380) D/OneSignal: curActivity is NOW: null

and

D/OneSignal: registerUser: registerForPushFired:true, locationFired: true, awlFired: true D/OneSignal: OneSignalRestClient: Making request to: https://onesignal.com/api/v1/players/xxxxx-xxxxx-xxxxx-xxxxx/on\_session D/OneSignal: OneSignalRestClient: POST SEND JSON: {"app\_id":"xxxxx-xxxxx-xxxxx-xxxxx"} V/OneSignal: OneSignalRestClient: After con.getResponseCode  to: https://onesignal.com/api/v1/players/xxxxx-xxxxx-xxxxx-xxxxx/on\_session D/OneSignal: OneSignalRestClient: Successfully finished request to: https://onesignal.com/api/v1/players/xxxxx-xxxxx-xxxxx-xxxxx/on\_session D/OneSignal: POST RECEIVED JSON: {"success":true,"id":"xxxxx-xxxxx-xxxxx-xxxxx"} I/OneSignal: Device registered, UserId = xxxxx-xxxxx-xxxxx-xxxxx W/System.err: com.naef.jnlua.LuaRuntimeException: attempt to call a number value W/System.err:     at com.naef.jnlua.LuaState.lua\_pcall(Native Method) W/System.err:     at com.naef.jnlua.LuaState.call(Unknown Source:4) W/System.err:     at OneSignal.LuaLoader$GetTagsFunction$CoronaGetTagsHandler$1$1.executeUsing(LuaLoader.java:263) W/System.err:     at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:195) W/System.err:     at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:116) W/System.err:     at com.ansca.corona.Controller.updateRuntimeState(Controller.java:343) W/System.err:     at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:450) W/System.err:     at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1625) W/System.err:     at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1380)

once either of these occur, the app will crash within one or two actions.   

I’ve been able to easily reproduce this issue with a simple native application as well as a simple lua-only application built by Corona’s servers.

Has anyone else encountered this issue on Android?

I have been using the rest call so I don’t have this issue. If you have the userId you can retrieve the tags by issuing a get request with the Id of the player:

https://onesignal.com/api/v1/players/\<idOfPlayer\>&nbsp;

Then the tag will be at the root of the document:

{ "id": "xxxx", "identifier": "xxxx", "session\_count": 992, "language": "es", "timezone": -10800, "game\_version": "2203", "device\_os": "6.0.1", "device\_type": 1, "device\_model": "SM-G903M", "ad\_id": "xxx", "tags": { "gsUserId": "xxxx" }, "last\_active": 1554418720, "playtime": 594394, "amount\_spent": 0, "created\_at": 1505781269, "invalid\_identifier": false, "badge\_count": 0, "sdk": "020550", "test\_type": null, "ip": "xxx", "external\_user\_id": null }

I think I might have to.  The Android plugin is just so broken for tags.  There’s yet another crash that will happen if you try to delete a tag that doesn’t exist.

W/System.err: java.lang.NullPointerException: Attempt to invoke interface method 'void com.onesignal.OneSignal$ChangeTagsUpdateHandler.onSuccess(org.json.JSONObject)' on a null object reference W/System.err:&nbsp; &nbsp; &nbsp;at com.onesignal.OneSignal$11.run(OneSignal.java:1508) W/System.err:&nbsp; &nbsp; &nbsp;at com.onesignal.OneSignal.sendTags(OneSignal.java:1524) W/System.err:&nbsp; &nbsp; &nbsp;at com.onesignal.OneSignal.sendTags(OneSignal.java:1450) W/System.err:&nbsp; &nbsp; &nbsp;at OneSignal.LuaLoader$SendTagsFunction.invoke(LuaLoader.java:185) W/System.err:&nbsp; &nbsp; &nbsp;at com.naef.jnlua.LuaState.lua\_pcall(Native Method) W/System.err:&nbsp; &nbsp; &nbsp;at com.naef.jnlua.LuaState.call(Unknown Source) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:156) W/System.err:&nbsp; &nbsp; &nbsp;at network.NetworkRequest$LuaCallback$1.executeUsing(NetworkRequest.java:612) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:195) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:116) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.Controller.updateRuntimeState(Controller.java:343) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:450) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1625) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1380)

I have been using the rest call so I don’t have this issue. If you have the userId you can retrieve the tags by issuing a get request with the Id of the player:

https://onesignal.com/api/v1/players/\<idOfPlayer\>&nbsp;

Then the tag will be at the root of the document:

{ "id": "xxxx", "identifier": "xxxx", "session\_count": 992, "language": "es", "timezone": -10800, "game\_version": "2203", "device\_os": "6.0.1", "device\_type": 1, "device\_model": "SM-G903M", "ad\_id": "xxx", "tags": { "gsUserId": "xxxx" }, "last\_active": 1554418720, "playtime": 594394, "amount\_spent": 0, "created\_at": 1505781269, "invalid\_identifier": false, "badge\_count": 0, "sdk": "020550", "test\_type": null, "ip": "xxx", "external\_user\_id": null }

I think I might have to.  The Android plugin is just so broken for tags.  There’s yet another crash that will happen if you try to delete a tag that doesn’t exist.

W/System.err: java.lang.NullPointerException: Attempt to invoke interface method 'void com.onesignal.OneSignal$ChangeTagsUpdateHandler.onSuccess(org.json.JSONObject)' on a null object reference W/System.err:&nbsp; &nbsp; &nbsp;at com.onesignal.OneSignal$11.run(OneSignal.java:1508) W/System.err:&nbsp; &nbsp; &nbsp;at com.onesignal.OneSignal.sendTags(OneSignal.java:1524) W/System.err:&nbsp; &nbsp; &nbsp;at com.onesignal.OneSignal.sendTags(OneSignal.java:1450) W/System.err:&nbsp; &nbsp; &nbsp;at OneSignal.LuaLoader$SendTagsFunction.invoke(LuaLoader.java:185) W/System.err:&nbsp; &nbsp; &nbsp;at com.naef.jnlua.LuaState.lua\_pcall(Native Method) W/System.err:&nbsp; &nbsp; &nbsp;at com.naef.jnlua.LuaState.call(Unknown Source) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:156) W/System.err:&nbsp; &nbsp; &nbsp;at network.NetworkRequest$LuaCallback$1.executeUsing(NetworkRequest.java:612) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:195) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:116) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.Controller.updateRuntimeState(Controller.java:343) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:450) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1625) W/System.err:&nbsp; &nbsp; &nbsp;at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1380)