@Test public void createInstallationInBackground() throws Exception { Assert.assertFalse(callbackFlag); NCMBInstallationService installationService = (NCMBInstallationService) NCMB.factory(NCMB.ServiceType.INSTALLATION); installationService.createInstallationInBackground("xxxxxxxxxxxxxxxxxxx", new JSONObject(), new ExecuteServiceCallback() { @Override public void done(JSONObject json, NCMBException e) { Assert.assertNull(e); try { Assert.assertEquals("7FrmPTBKSNtVjajm", json.getString("objectId")); } catch (JSONException error) { Assert.assertNull(error); } callbackFlag = true; } }); Robolectric.flushBackgroundThreadScheduler(); ShadowLooper.runUiThreadTasks(); Assert.assertTrue(callbackFlag); }
public void createInstallationInBackground(String registrationId, JSONObject params, final ExecuteServiceCallback callback) { try { final JSONObject argumentParams = argumentNullCheckForPOST(registrationId, params); try { params.put("deviceToken", registrationId); setInstallationBasicData(params); } catch (JSONException e) { throw new NCMBException(NCMBException.INVALID_JSON, "Invalid json format."); } catch (PackageManager.NameNotFoundException e) { throw new NCMBException(NCMBException.DATA_NOT_FOUND, "PackageManager not found."); } RequestParams request = createRequestParams(null, params, null, NCMBRequest.HTTP_METHOD_POST); sendRequestAsync(request, new InstallationServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { NCMBException error = null; try { writeCurrentInstallation(argumentParams, response.responseData); } catch (NCMBException e) { error = e; } ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(response.responseData, error); } } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException error) { if (callback != null) { callback.done(null, error); } } }
NCMBInstallationService extends NCMBService { public void createInstallationInBackground(String registrationId, JSONObject params, final ExecuteServiceCallback callback) { try { final JSONObject argumentParams = argumentNullCheckForPOST(registrationId, params); try { params.put("deviceToken", registrationId); setInstallationBasicData(params); } catch (JSONException e) { throw new NCMBException(NCMBException.INVALID_JSON, "Invalid json format."); } catch (PackageManager.NameNotFoundException e) { throw new NCMBException(NCMBException.DATA_NOT_FOUND, "PackageManager not found."); } RequestParams request = createRequestParams(null, params, null, NCMBRequest.HTTP_METHOD_POST); sendRequestAsync(request, new InstallationServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { NCMBException error = null; try { writeCurrentInstallation(argumentParams, response.responseData); } catch (NCMBException e) { error = e; } ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(response.responseData, error); } } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException error) { if (callback != null) { callback.done(null, error); } } } }
NCMBInstallationService extends NCMBService { public void createInstallationInBackground(String registrationId, JSONObject params, final ExecuteServiceCallback callback) { try { final JSONObject argumentParams = argumentNullCheckForPOST(registrationId, params); try { params.put("deviceToken", registrationId); setInstallationBasicData(params); } catch (JSONException e) { throw new NCMBException(NCMBException.INVALID_JSON, "Invalid json format."); } catch (PackageManager.NameNotFoundException e) { throw new NCMBException(NCMBException.DATA_NOT_FOUND, "PackageManager not found."); } RequestParams request = createRequestParams(null, params, null, NCMBRequest.HTTP_METHOD_POST); sendRequestAsync(request, new InstallationServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { NCMBException error = null; try { writeCurrentInstallation(argumentParams, response.responseData); } catch (NCMBException e) { error = e; } ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(response.responseData, error); } } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException error) { if (callback != null) { callback.done(null, error); } } } NCMBInstallationService(NCMBContext context); }
NCMBInstallationService extends NCMBService { public void createInstallationInBackground(String registrationId, JSONObject params, final ExecuteServiceCallback callback) { try { final JSONObject argumentParams = argumentNullCheckForPOST(registrationId, params); try { params.put("deviceToken", registrationId); setInstallationBasicData(params); } catch (JSONException e) { throw new NCMBException(NCMBException.INVALID_JSON, "Invalid json format."); } catch (PackageManager.NameNotFoundException e) { throw new NCMBException(NCMBException.DATA_NOT_FOUND, "PackageManager not found."); } RequestParams request = createRequestParams(null, params, null, NCMBRequest.HTTP_METHOD_POST); sendRequestAsync(request, new InstallationServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { NCMBException error = null; try { writeCurrentInstallation(argumentParams, response.responseData); } catch (NCMBException e) { error = e; } ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(response.responseData, error); } } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException error) { if (callback != null) { callback.done(null, error); } } } NCMBInstallationService(NCMBContext context); JSONObject createInstallation(String registrationId, JSONObject params); void createInstallationInBackground(String registrationId, JSONObject params, final ExecuteServiceCallback callback); JSONObject updateInstallation(String objectId, JSONObject params); void updateInstallationInBackground(final String objectId, JSONObject params, final ExecuteServiceCallback callback); void deleteInstallation(String objectId); void deleteInstallationInBackground(final String objectId, DoneCallback callback); NCMBInstallation fetchInstallation(String objectId); void fetchInstallationInBackground(String objectId, final FetchCallback callback); List searchInstallation(JSONObject conditions); void searchInstallationInBackground(JSONObject conditions, final SearchInstallationCallback callback); }
NCMBInstallationService extends NCMBService { public void createInstallationInBackground(String registrationId, JSONObject params, final ExecuteServiceCallback callback) { try { final JSONObject argumentParams = argumentNullCheckForPOST(registrationId, params); try { params.put("deviceToken", registrationId); setInstallationBasicData(params); } catch (JSONException e) { throw new NCMBException(NCMBException.INVALID_JSON, "Invalid json format."); } catch (PackageManager.NameNotFoundException e) { throw new NCMBException(NCMBException.DATA_NOT_FOUND, "PackageManager not found."); } RequestParams request = createRequestParams(null, params, null, NCMBRequest.HTTP_METHOD_POST); sendRequestAsync(request, new InstallationServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { NCMBException error = null; try { writeCurrentInstallation(argumentParams, response.responseData); } catch (NCMBException e) { error = e; } ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(response.responseData, error); } } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException error) { if (callback != null) { callback.done(null, error); } } } NCMBInstallationService(NCMBContext context); JSONObject createInstallation(String registrationId, JSONObject params); void createInstallationInBackground(String registrationId, JSONObject params, final ExecuteServiceCallback callback); JSONObject updateInstallation(String objectId, JSONObject params); void updateInstallationInBackground(final String objectId, JSONObject params, final ExecuteServiceCallback callback); void deleteInstallation(String objectId); void deleteInstallationInBackground(final String objectId, DoneCallback callback); NCMBInstallation fetchInstallation(String objectId); void fetchInstallationInBackground(String objectId, final FetchCallback callback); List searchInstallation(JSONObject conditions); void searchInstallationInBackground(JSONObject conditions, final SearchInstallationCallback callback); static final String SERVICE_PATH; static final int HTTP_STATUS_INSTALLATION_CREATED; static final int HTTP_STATUS_INSTALLATION_UPDATED; static final int HTTP_STATUS_INSTALLATION_DELETED; static final int HTTP_STATUS_INSTALLATION_GOTTEN; }