Overview

Skill Level: Intermediate

Action plugins can be used to extend the behavior executed when a message is interacted with. Push messages, InApp messages and Inbox messages all use actions to define what happens when a user interacts with them. You can register your own action handlers written in javascript using the [`registerAction`](react-native-acoustic-mobile-push.html#user-content-registeractiontype-callback) function. (See the send-email-action.js in the sample application for an example).

Prerequisites

Not what you’re looking for? Check out all our available tutorials for mobile app messaging here.

 

 

 

Step-by-step

  1. Use the following native action plugins to extend your apps capabilities

    Custom actions can also be written in javascript:

    import {NativeEventEmitter} from 'react-native';
    import {RNAcousticMobilePushActionHandler} from 'NativeModules';
    
    const emitter = new NativeEventEmitter(RNAcousticMobilePushActionHandler);
    
    export default function demonstrationAction(details) {
    // details.action contains the specific action payload ie {"type": "demonstration", "value": "acoustic"}
    // details.payload contains the entire push payload ie { "aps": { "alert": "test" }, "notification-action": {"type": "demonstration", "value": "acoustic"} }
    
    // You can place code here to use the values in those payloads to perform work on behalf of the user
    }
    
    // The registerAction call tells the SDK that you intend to handle actions of this type. In addition the function passed will be called for any missed actions received while your code was not running.
    RNAcousticMobilePushActionHandler.registerAction('demonstration', demonstrationAction);
    
    // The listener call allows this function to be called when actions arrive
    emitter.addListener('demonstration', demonstrationAction);
    

Expected outcome

Need more help? Check out all of our available tutorials for mobile app messaging here.

Join The Discussion

Your email address will not be published. Required fields are marked *