pundixit / capacitor-pushiomanager

Universal Permissive License v1.0
0 stars 0 forks source link

Capacitor Plugin for Responsys SDK

This plugin makes it easy to integrate your Capacitor based mobile app with the Responsys SDK.

Table of Contents

Requirements

For Android

For iOS

Setup

Before installing the plugin, you must setup your app to receive push notifications.

For Android

For iOS

Installation

Download the plugin,

git clone https://github.com/pundixit/capacitor-pushiomanager

For Android

For iOS

The plugin can be installed with the Capacitor CLI,

npm install PATH_TO_pushiomanager-Capacitor-plugin_DIRECTORY

npm cap sync

Integration

For Android

For iOS

Add below code in AppDelegate.swift

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: deviceToken)
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {

    return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
  }

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
   return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler)
  }

Usage

The plugin can be accessed in JS code using the namespace PushIOManager. The following code samples use PushIOManager for the namespace.

Configure And Register

User Identification

Engagements And Conversion

User actions can be attributed to a push notification using,

PushIOManager.trackEngagement({eventName:PushIOManager.engagementType.PUSHIO_ENGAGEMENT_METRIC_INAPP_PURCHASE}).then((response) => {

        if (response.success) {

        } else if (response.error){

        }

    }).catch(error => {
       console.log("error" + error);
   });

In-App Messages

In-App Message (IAM) are displayed in a popup window via system-defined triggers like $ExplicitAppOpen or custom triggers. IAM that use system-defined triggers are displayed automatically.

IAM can also be displayed on-demand using custom triggers.

Message Center

Geofences And Beacons

If your app is setup to monitor geofence and beacons, you can use the following APIs to record in Responsys when a user enters/exits a geofence/beacon zone.

PushIOManager.onGeoRegionEntered({region:geoRegion}).then( (response) => {});
PushIOManager.onGeoRegionExited({region:geoRegion}).then( (response) => {});
PushIOManager.onBeaconRegionEntered({region:beaconRegion}).then((response) => {});
PushIOManager.onBeaconRegionExited({region:beaconRegion}).then( (response) => {});

Notification Preferences

Preferences are used to record user-choices for push notifications. The preferences should be pre-defined in Responsys before being used in your app.

Do not use this as a key/value store as this data is purgeable.

Handling Deeplinks

When the user taps on a push notification (having a deeplink), the plugin passes the deeplink to the app.

Add interceptOpenURL:true in capacitor.config.js file of App

"plugins":{
        "PushIOManager": {
            "interceptOpenURL": true
        }
    }

App must implement the following listener to handle deeplinks.

PushIOManager.addListener('setInterceptOpenURL', (response) => {
           console.log('Deep link url' + response["url"]);

  });

Support

If you have access to My Oracle Support, please raise a request here, otherwise open an issue in this repository.

License

Copyright (c) 2023 Oracle and/or its affiliates and released under the Universal Permissive License (UPL), Version 1.0.

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.