private void executeAppInvite(JSONArray args, CallbackContext callbackContext) { String appLinkUrl = null; String previewImageUrl = null; Map<String, String> params = new HashMap<String, String>(); String method = null; JSONObject parameters; try { parameters = args.getJSONObject(0); } catch (JSONException e) { parameters = new JSONObject(); } Iterator<String> iter = parameters.keys(); while (iter.hasNext()) { String key = iter.next(); if (key.equals("url")) { try { appLinkUrl = parameters.getString(key); } catch (JSONException e) { Log.w(TAG, "Nonstring method parameter provided to dialog"); callbackContext.error("Incorrect parameter 'url'."); return; } } else if (key.equals("picture")) { try { previewImageUrl = parameters.getString(key); } catch (JSONException e) { Log.w(TAG, "Non-string parameter provided to dialog discarded"); callbackContext.error("Incorrect parameter 'picture'."); return; } } } if (appLinkUrl == null || previewImageUrl == null) { callbackContext.error("Both 'url' and 'picture' parameter needed"); return; } if (AppInviteDialog.canShow()) { AppInviteContent content = new AppInviteContent.Builder() .setApplinkUrl(appLinkUrl) .setPreviewImageUrl(previewImageUrl) .build(); appInviteDialog.show(content); } }