urbanairship-core/src/main/java/com/urbanairship/widget/UAWebViewClient.java
private void runAction(final WebView webView, final String name, final String value, final String callbackKey) {
        // Parse the action value
        ActionValue actionValue;
        try {
            actionValue = new ActionValue(JsonValue.parseString(value));
        } catch (JsonException e) {
            Logger.error("Unable to parse action argument value: " + value, e);
            triggerCallback(webView, "Unable to decode arguments payload", new ActionValue(), callbackKey);
            return;
        }

        // Create metadata
        Bundle metadata = new Bundle();
        RichPushMessage message = getMessage(webView);
        if (message != null) {
            metadata.putString(ActionArguments.RICH_PUSH_ID_METADATA, message.getMessageId());
        }

        // Run the action
        actionRunRequestFactory.createActionRequest(name)
                               .setMetadata(metadata)
                               .setValue(actionValue)
                               .setSituation(Action.SITUATION_WEB_VIEW_INVOCATION)
                               .run(new ActionCompletionCallback() {
                                   @Override
                                   public void onFinish(@NonNull ActionArguments arguments, @NonNull ActionResult result) {

                                       String errorMessage = null;
                                       switch (result.getStatus()) {
                                           case ActionResult.STATUS_COMPLETED:
                                               break;
                                           case ActionResult.STATUS_ACTION_NOT_FOUND:
                                               errorMessage = String.format("Action %s not found", name);
                                               break;
                                           case ActionResult.STATUS_REJECTED_ARGUMENTS:
                                               errorMessage = String.format("Action %s rejected its arguments", name);
                                               break;
                                           case ActionResult.STATUS_EXECUTION_ERROR:
                                               if (result.getException() != null) {
                                                   errorMessage = result.getException().getMessage();
                                               } else {
                                                   errorMessage = String.format("Action %s failed with unspecified error", name);
                                               }
                                       }

                                       triggerCallback(webView, errorMessage, result.getValue(), callbackKey);

                                       synchronized (this) {
                                           if (actionCompletionCallback != null) {
                                               actionCompletionCallback.onFinish(arguments, result);
                                           }
                                       }
                                   }
                               });
    }
/**
     * Runs a single action by name, and performs callbacks into the JavaScript layer with results.
     *
     * @param webView The web view.
     * @param name The name of the action to run.
     * @param value A JSON-encoded string representing the action value.
     * @param callbackKey The key for the callback function in JavaScript.
     */
Runs a single action by name, and performs callbacks into the JavaScript layer with results.
@param webView The web view.
@param name The name of the action to run.
@param value A JSON-encoded string representing the action value.
@param callbackKey The key for the callback function in JavaScript.
Runs a single action by name and performs callbacks into the JavaScript layer with results . @param webView The web view . @param name The name of the action to run . @param value A JSON - encoded string representing the action value . @param callbackKey The key for the callback function in JavaScript .
private void runAction(final WebView webView, final String name, final String value, final String callbackKey) {
        ActionValue actionValue;
        try {
            actionValue = new ActionValue(JsonValue.parseString(value));
        } catch (JsonException e) {
            Logger.error("Unable to parse action argument value: " + value, e);
            triggerCallback(webView, "Unable to decode arguments payload", new ActionValue(), callbackKey);
            return;
        }
        Bundle metadata = new Bundle();
        RichPushMessage message = getMessage(webView);
        if (message != null) {
            metadata.putString(ActionArguments.RICH_PUSH_ID_METADATA, message.getMessageId());
        }
        actionRunRequestFactory.createActionRequest(name)
                               .setMetadata(metadata)
                               .setValue(actionValue)
                               .setSituation(Action.SITUATION_WEB_VIEW_INVOCATION)
                               .run(new ActionCompletionCallback() {
                                   @Override
                                   public void onFinish(@NonNull ActionArguments arguments, @NonNull ActionResult result) {
                                       String errorMessage = null;
                                       switch (result.getStatus()) {
                                           case ActionResult.STATUS_COMPLETED:
                                               break;
                                           case ActionResult.STATUS_ACTION_NOT_FOUND:
                                               errorMessage = String.format("Action %s not found", name);
                                               break;
                                           case ActionResult.STATUS_REJECTED_ARGUMENTS:
                                               errorMessage = String.format("Action %s rejected its arguments", name);
                                               break;
                                           case ActionResult.STATUS_EXECUTION_ERROR:
                                               if (result.getException() != null) {
                                                   errorMessage = result.getException().getMessage();
                                               } else {
                                                   errorMessage = String.format("Action %s failed with unspecified error", name);
                                               }
                                       }
                                       triggerCallback(webView, errorMessage, result.getValue(), callbackKey);
                                       synchronized (this) {
                                           if (actionCompletionCallback != null) {
                                               actionCompletionCallback.onFinish(arguments, result);
                                           }
                                       }
                                   }
                               });
    }
private void runAction ( final WebView webView , final String name , final String value , final String callbackKey ) { ActionValue actionValue ; try { actionValue = new ActionValue ( JsonValue . parseString ( value ) ) ; } catch ( JsonException e ) { Logger . error ( "Unable to parse action argument value: " + value , e ) ; triggerCallback ( webView , "Unable to decode arguments payload" , new ActionValue ( ) , callbackKey ) ; return ; } Bundle metadata = new Bundle ( ) ; RichPushMessage message = getMessage ( webView ) ; if ( message != null ) { metadata . putString ( ActionArguments . RICH_PUSH_ID_METADATA , message . getMessageId ( ) ) ; } actionRunRequestFactory . createActionRequest ( name ) . setMetadata ( metadata ) . setValue ( actionValue ) . setSituation ( Action . SITUATION_WEB_VIEW_INVOCATION ) . run ( new ActionCompletionCallback ( ) { @ Override public void onFinish ( @ NonNull ActionArguments arguments , @ NonNull ActionResult result ) { String errorMessage = null ; switch ( result . getStatus ( ) ) { case ActionResult . STATUS_COMPLETED : break ; case ActionResult . STATUS_ACTION_NOT_FOUND : errorMessage = String . format ( "Action %s not found" , name ) ; break ; case ActionResult . STATUS_REJECTED_ARGUMENTS : errorMessage = String . format ( "Action %s rejected its arguments" , name ) ; break ; case ActionResult . STATUS_EXECUTION_ERROR : if ( result . getException ( ) != null ) { errorMessage = result . getException ( ) . getMessage ( ) ; } else { errorMessage = String . format ( "Action %s failed with unspecified error" , name ) ; } } triggerCallback ( webView , errorMessage , result . getValue ( ) , callbackKey ) ; synchronized ( this ) { if ( actionCompletionCallback != null ) { actionCompletionCallback . onFinish ( arguments , result ) ; } } } } ) ; }
Runs a single action by name, and performs callbacks into the JavaScript layer with results.
Runs a single action by name and performs callbacks into the JavaScript layer with results .
// Parse the action value // Create metadata // Run the action