Created
January 30, 2017 15:06
-
-
Save mrs110/eaef272cf76db9ef8db9937a80bb95f9 to your computer and use it in GitHub Desktop.
Trying to wrap connect()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void init(JSONArray args) throws JSONException{ | |
| // args contains the arguments for initialization. these must be unwrapped. | |
| for (int i=0; i==5; i++) { | |
| if (args.getString(i) == null || args.getString(i).length() <= 0) { | |
| callbackContext.error(TAG + ": initialization failed. Are you passing the correct parameters?"); | |
| } | |
| } | |
| // Get arguments passed in | |
| // Endpoints are a bit special, since they come as an array and have | |
| // to be passed on as String[] | |
| JSONArray endpointUrlsArray = new JSONArray(args.getString(0)); | |
| String[] endpointUrls = new String[endpointUrlsArray.length()]; | |
| for(int i = 0; i < endpointUrlsArray.length(); i++){ | |
| endpointUrls[i] = endpointUrlsArray.getString(i); | |
| } | |
| String apiKey = args.getString(1); | |
| String appVersion = args.getString(2); | |
| String iknr = args.getString(3); | |
| String baseWebserviceUrl = args.getString(4); | |
| String apnsToken = args.getString(5); | |
| PhotoSdkParameters parameters = new PhotoSdkParameters(); | |
| parameters.setEndpointURLs(endpointUrls); | |
| parameters.setApiKey(apiKey); | |
| parameters.setAppVersion(appVersion); | |
| parameters.setIKNR(iknr); | |
| parameters.setBaseWebserviceUrl(baseWebserviceUrl); | |
| parameters.setAPNSToken(apnsToken); | |
| PhotoSDK.getInstance().init(this.application, parameters); | |
| callbackContext.success(TAG + ": successfully initialized FotoApp SDK"); | |
| } | |
| private void connect(){ | |
| // neither one of the callbacks is called (success or error). The console log only output "JSON error" | |
| PhotoSDK.getInstance().connect(new MqttConnectCallback() { | |
| @Override | |
| public void onSuccess(Response<String> response) { | |
| callbackContext.success(TAG + ": successfully connected FotoApp SDK"); | |
| } | |
| @Override | |
| public void onFailure(BluePostBoxError bluePostBoxError) { | |
| AppErrorManager.getInstance().processErrorCode(activity, bluePostBoxError); | |
| callbackContext.error(TAG + ": couldn't connect FotoApp SDK"); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment