npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-accengage

v1.4.2

Published

Accengage ReactNative module.

Downloads

38

Readme

react-native-accengage

ReactNative module for Accengage Version 1.4.2

Installation

npm install --save react-native-accengage
react-native link react-native-accengage

iOS

This module acts purely as a bridge for calling Accengage methods in ReactNative. Please follow the Accengage documentation on their website, on how to setup with appId and privateKey. This will mean making changes to your AppDelegate.

Android

This module acts purely as a bridge for calling Accengage methods in ReactNative, but the gradle file will link to the A4S SDK as well. Please follow the Accengage documentation on their website, on how to setup with appId and privateKey. This will mean making changes to your Application.java.

Usage

// Import
import Accengage from 'react-native-accengage';

Implemented calls:

/**
 * Check if user has granted push permissions
 * @param callback Called with boolean
 */
Accengage.hasPermissions(RNAccengageModule, result => {
  // result
});

/**
 * Request push permissions, android will ignore this.
 * @param userAction Boolean When this is true, the settings app will be opened if the user didn't 
 *                           grant permissions. 
 */
Accengage.requestPermissions(userAction);

/**
 * Update push tokens
 * This should be called every time you open the app
 * It will never trigger a dialog or open the settings app
 */
Accengage.updateTokens();

/**
 * Track a custom event to enable segmentation in Accengage.
 * The key used should be setup in Accengage dashboard before use.
 * @param key Custom key for Accengage tracking
 */
Accengage.trackEvent(key);

/**
 * Track a custom event to enable segmentation in Accengage.
 * The key used should be setup in Accengage dashboard before use.
 * @param key Custom key for Accengage tracking
 * @param customData An object with custom data to send along
 */
Accengage.trackEventWithCustomData(key, customData);

/**
 * Track a lead
 * @param label
 * @param value
 */
Accengage.trackLead(labelLabel, leadValue);

/**
* Update device info
* The object keys and values should be strings.
* Date values should be strings formatted like: yyyy-MM-dd HH:mm:ss zzz
* @param object
*/
Accengage.updateDeviceInfo(object);

/**
* Get Inbox Messages
* Returns an array of a maximum of 20 Messages.
* @param object
*/
Accengage.getInboxMessages();

/**
* Get Message
* Returns a single message given an index.
* Before calling this method, getInboxMessages() should be invocated.
* @param index
* @return Promise with either a message or null (in which case a webview is opened)
*/
Accengage.getMessage(index);

/**
* Interact with button in message content
* @param messageIndex
* @param buttonIndex
* @return Promise with an Accengage Inbox Message or error
*/
function interactWithButton(messageIndex, buttonIndex) {
  return RNAccengageModule.interactWithButton(buttonIndex, messageIndex);
}

/**
* Mark message as read
* Read a message. Returns the message with the new value.
* Before calling this method, getInboxMessages() should be invocated.
* @param index
* @param bool
*/
Accengage.markMessageAsRead(index, bool);

/**
* Mark message as displayed
* @param index
* @param isDisplayed
* @return Promise with an Accengage Inbox Message or error
*/
function markMessageAsDisplayed(index, isDisplayed) {
return RNAccengageModule.markMessageAsDisplayed(index, isDisplayed);
}

/**
* Mark message as archived
* Archive a message. Returns the message with the new value.
* Before calling this method, getInboxMessages() should be invocated.
* @param index
* @param bool
*/
Accengage.markMessageAsArchived(index, bool);

/**
* Track display
* @param index
* @return Promise with an Accengage Inbox Message or error
*/
function trackDisplay(index) {
return RNAccengageModule.trackDisplay(index);
}

/**
* Track opening
* @param index
* @return Promise with an Accengage Inbox Message or error
*/
function trackOpening(index) {
return RNAccengageModule.trackOpening(index);
}

/**
* Clear the message cache
*/
function clearMessages() {
RNAccengageModule.clearMessages();
}

Message Format

When a message was succefully retrieved, it will have the following structure:

{
  type: "message",
  index: Integer,
  subject: String,
  category: String,
  summary: String,
  timestamp: Timestamp/null
  sender: String,
  read: Boolean,
  archived: Boolean,
  customParameters: Object,
}

Due too the way the Accengage SDK is setup, you need to do seperate message detail calls to be able to fill a list. As some of those can fail, the list can contain messages of the following structure as well. In which case you can show a row with a retry button for example.

{
  type: "error",
  index: Integer
}

Error Handling

When an inbox call fails, it will reject a promise. These are the codes you can handle:

loading_inbox_failed When the very first call to Accengage fails

loading_message_failed Only in case of retrieving a single message

already_loading When you try to load a list, while a previous one was still loading

general_error These are errors that shouldn't happen. Think of memory issues or async calls finishing after cleanup. Examples:

  • Inbox was null
  • Inbox doesn't exist anymore
  • Messages disappeared
  • Couldn't find the message to mark read/archived