0

I have attached the trigger point code for Facebook App invite dialog.I get callback for onActivityResult but the callback will not be received for the app invite callbacks registered using facebook callback registers. I have tried the same code in native working perfectly fine.But when i develop cordova plugin for android platform facing issue with the callback.PLEASE HELP

    if (AppInviteDialog.canShow()) {
        AppInviteContent.Builder builder = new AppInviteContent.Builder();
        builder.setApplinkUrl(url);
        if (picture != null) {
            builder.setPreviewImageUrl(picture);
        }

        showDialogContext = callbackContext;
        PluginResult pr = new PluginResult(PluginResult.Status.NO_RESULT);
        pr.setKeepCallback(true);
        showDialogContext.sendPluginResult(pr);

        cordova.setActivityResultCallback(this);
        AppInviteDialog appInviteDialog = new AppInviteDialog(cordova.getActivity());
        appInviteDialog.show(builder.build());
        appInviteDialog.registerCallback(callbackManager, new FacebookCallback<AppInviteDialog.Result>() {
            @Override
            public void onSuccess(AppInviteDialog.Result result) {
                if (showDialogContext != null) {
                    try {
                        JSONObject json = new JSONObject();
                        Bundle bundle = result.getData();
                        for (String key : bundle.keySet()) {
                            json.put(key, wrapObject(bundle.get(key)));
                        }

                        showDialogContext.success(json);
                        showDialogContext = null;
                    } catch (JSONException e) {
                        showDialogContext.success();
                        showDialogContext = null;
                    }
                }
            }

            @Override
            public void onCancel() {
                FacebookOperationCanceledException e = new FacebookOperationCanceledException();
                handleError(e, showDialogContext);
            }

            @Override
            public void onError(FacebookException error) {
                Log.e("Activity", String.format("Error: %s", error.toString()));
                handleError(error, showDialogContext);
            }
        });
    } else {
        callbackContext.error("Unable to show dialog");
    }

0 Answers0