@Test public void getPushInBackground() throws Exception { Assert.assertFalse(callbackFlag); NCMBPushService pushService = (NCMBPushService) NCMB.factory(NCMB.ServiceType.PUSH); pushService.fetchPushInBackground("7FrmPTBKSNtVjajm", new FetchCallback<NCMBPush>() { @Override public void done(NCMBPush push, NCMBException e) { Assert.assertNull(e); Assert.assertEquals("7FrmPTBKSNtVjajm", push.getString("objectId")); Assert.assertEquals("http: callbackFlag = true; } }); Robolectric.flushBackgroundThreadScheduler(); ShadowLooper.runUiThreadTasks(); Assert.assertTrue(callbackFlag); }
public void fetchPushInBackground(final String pushId, final FetchCallback callback) { try { if (pushId == null) { throw new NCMBException(NCMBException.INVALID_JSON, "pushId must no be null"); } RequestParams request = createRequestParams(pushId, null, null, NCMBRequest.HTTP_METHOD_GET); sendRequestAsync(request, new PushServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response){ FetchCallback<NCMBPush> callback = (FetchCallback) mCallback; if (callback != null) { callback.done(new NCMBPush(response.responseData), null); } } @Override public void handleError(NCMBException e) { if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException error) { if (callback != null) { callback.done(null, error); } } }
NCMBPushService extends NCMBService { public void fetchPushInBackground(final String pushId, final FetchCallback callback) { try { if (pushId == null) { throw new NCMBException(NCMBException.INVALID_JSON, "pushId must no be null"); } RequestParams request = createRequestParams(pushId, null, null, NCMBRequest.HTTP_METHOD_GET); sendRequestAsync(request, new PushServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response){ FetchCallback<NCMBPush> callback = (FetchCallback) mCallback; if (callback != null) { callback.done(new NCMBPush(response.responseData), null); } } @Override public void handleError(NCMBException e) { if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException error) { if (callback != null) { callback.done(null, error); } } } }
NCMBPushService extends NCMBService { public void fetchPushInBackground(final String pushId, final FetchCallback callback) { try { if (pushId == null) { throw new NCMBException(NCMBException.INVALID_JSON, "pushId must no be null"); } RequestParams request = createRequestParams(pushId, null, null, NCMBRequest.HTTP_METHOD_GET); sendRequestAsync(request, new PushServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response){ FetchCallback<NCMBPush> callback = (FetchCallback) mCallback; if (callback != null) { callback.done(new NCMBPush(response.responseData), null); } } @Override public void handleError(NCMBException e) { if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException error) { if (callback != null) { callback.done(null, error); } } } NCMBPushService(NCMBContext context); }
NCMBPushService extends NCMBService { public void fetchPushInBackground(final String pushId, final FetchCallback callback) { try { if (pushId == null) { throw new NCMBException(NCMBException.INVALID_JSON, "pushId must no be null"); } RequestParams request = createRequestParams(pushId, null, null, NCMBRequest.HTTP_METHOD_GET); sendRequestAsync(request, new PushServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response){ FetchCallback<NCMBPush> callback = (FetchCallback) mCallback; if (callback != null) { callback.done(new NCMBPush(response.responseData), null); } } @Override public void handleError(NCMBException e) { if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException error) { if (callback != null) { callback.done(null, error); } } } NCMBPushService(NCMBContext context); JSONObject sendPush(JSONObject params); void sendPushInBackground(final JSONObject params, ExecuteServiceCallback callback); JSONObject updatePush(String pushId, JSONObject params); void updatePushInBackground(final String pushId, final JSONObject params, final ExecuteServiceCallback callback); void deletePush(String pushId); void deletePushInBackground(String pushId, DoneCallback callback); NCMBPush fetchPush(String pushId); void fetchPushInBackground(final String pushId, final FetchCallback callback); List searchPush(JSONObject conditions); void searchPushInBackground(JSONObject conditions, final SearchPushCallback callback); void sendPushReceiptStatusInBackground(String pushId, ExecuteServiceCallback callback); }
NCMBPushService extends NCMBService { public void fetchPushInBackground(final String pushId, final FetchCallback callback) { try { if (pushId == null) { throw new NCMBException(NCMBException.INVALID_JSON, "pushId must no be null"); } RequestParams request = createRequestParams(pushId, null, null, NCMBRequest.HTTP_METHOD_GET); sendRequestAsync(request, new PushServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response){ FetchCallback<NCMBPush> callback = (FetchCallback) mCallback; if (callback != null) { callback.done(new NCMBPush(response.responseData), null); } } @Override public void handleError(NCMBException e) { if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException error) { if (callback != null) { callback.done(null, error); } } } NCMBPushService(NCMBContext context); JSONObject sendPush(JSONObject params); void sendPushInBackground(final JSONObject params, ExecuteServiceCallback callback); JSONObject updatePush(String pushId, JSONObject params); void updatePushInBackground(final String pushId, final JSONObject params, final ExecuteServiceCallback callback); void deletePush(String pushId); void deletePushInBackground(String pushId, DoneCallback callback); NCMBPush fetchPush(String pushId); void fetchPushInBackground(final String pushId, final FetchCallback callback); List searchPush(JSONObject conditions); void searchPushInBackground(JSONObject conditions, final SearchPushCallback callback); void sendPushReceiptStatusInBackground(String pushId, ExecuteServiceCallback callback); static final String SERVICE_PATH; static final int HTTP_STATUS_PUSH_CREATED; static final int HTTP_STATUS_PUSH_UPDATED; static final int HTTP_STATUS_PUSH_DELETED; static final int HTTP_STATUS_PUSH_GOTTEN; static final int HTTP_STATUS_PUSH_RECEIPTSTATUS; }