Search in sources :

Example 1 with ChangeTagsUpdateHandler

use of com.onesignal.OneSignal.ChangeTagsUpdateHandler in project OneSignal-Android-SDK by OneSignal.

the class UserStateSynchronizer method sendTagsHandlersPerformOnSuccess.

private void sendTagsHandlersPerformOnSuccess() {
    JSONObject tags = OneSignalStateSynchronizer.getTags(false).result;
    ChangeTagsUpdateHandler handler;
    while ((handler = sendTagsHandlers.poll()) != null) handler.onSuccess(tags);
}
Also used : JSONObject(org.json.JSONObject) ChangeTagsUpdateHandler(com.onesignal.OneSignal.ChangeTagsUpdateHandler)

Example 2 with ChangeTagsUpdateHandler

use of com.onesignal.OneSignal.ChangeTagsUpdateHandler in project OneSignal-Android-SDK by OneSignal.

the class MainOneSignalClassRunner method testNestedSendTagsOnSuccess.

@Test
public void testNestedSendTagsOnSuccess() throws Exception {
    final JSONObject tags = new JSONObject().put("key", "value");
    OneSignalInit();
    OneSignal.sendTags(tags);
    threadAndTaskWait();
    // Sending same tags a 2nd time creates the issue, as it take a different code path
    OneSignal.sendTags(tags, new ChangeTagsUpdateHandler() {

        @Override
        public void onSuccess(JSONObject values) {
            OneSignal.sendTags(tags, new TestChangeTagsUpdateHandler());
        }

        @Override
        public void onFailure(OneSignal.SendTagsError error) {
        }
    });
    threadAndTaskWait();
}
Also used : OneSignal(com.onesignal.OneSignal) ShadowOneSignal(com.onesignal.ShadowOneSignal) JSONObject(org.json.JSONObject) ChangeTagsUpdateHandler(com.onesignal.OneSignal.ChangeTagsUpdateHandler) Test(org.junit.Test)

Aggregations

ChangeTagsUpdateHandler (com.onesignal.OneSignal.ChangeTagsUpdateHandler)2 JSONObject (org.json.JSONObject)2 OneSignal (com.onesignal.OneSignal)1 ShadowOneSignal (com.onesignal.ShadowOneSignal)1 Test (org.junit.Test)1