React Native Push Library
React native wrapper library for Unifonic Push
Installation
npm install react-native-unifonic-push
OR
yarn add react-native-unifonic-push
Usage
import { UnifonicPush } from 'react-native-unifonic-push';
// ...
const unifonicPush = new UnifonicPush(true);
const token = await unifonicPush.register("appId", "identifier");
API
The library exposes a single class UnifonicPush
The class has the following attributes and methods:
Constructor
constructor(isDev = false)
isDev
=> Optional boolean parameter to connect to development server. Defaults to false
Attributes
storedAppId
=> returns the application id stored locallystoredIdentifier
=> returns the identifier stored locallysdkToken
=> returns the sdk token stored locallypushToken
=> returns the push token stored locally
Methods
register
=> Registers your app with Unifonic
Parameters:
a.appId
: Refers to the App ID you receive from Unifonic
b.identifier
: A unique identifier
Returns:
sdkToken
: A token that you can use as authorization in subsequent requestsmarkNotification
=> Mark a notification as eitherread
orreceived
Parameters:
a.type
: NotificationReadType (read/received)
b.messageId
: Message ID received in push notification's payload
Returns:
boolean
:true
in case of success,false
otherwiseenableNotification
: Enables the notifications for the current device
Returns:
boolean
:true
in case of success,false
otherwisedisableNotification
: Disables the notifications for the current device
Returns:
boolean
:true
in case of success,false
otherwisesaveToken
: Sends the push-token to Unifonic backend
Parameters:
pushToken
:apn
in case of iOS,fcm
in case of Android
Returns:
boolean':
truein case of success,
false` otherwise
Updated 12 months ago