blueshift-react-native
Advanced tools
Comparing version 1.0.0-beta.1 to 1.0.0
187
Android.md
# Android Plugin Integration | ||
## Depend on Blueshift Android SDK | ||
## 1. SDK Integration | ||
To install the Blueshift Android SDK, add the following line to the app level `build.gradle` file. To know the latest version, check the [releases](https://github.com/blueshift-labs/Blueshift-Android-SDK/releases) page on Github. | ||
### Install Blueshift Android SDK | ||
To install the Blueshift Android SDK, add the following line to the app level `build.gradle` file. To know the latest version, check the [releases](https://github.com/blueshift-labs/Blueshift-Android-SDK/releases) page on **GitHub**. | ||
```groovy | ||
@@ -11,3 +13,3 @@ implementation "com.blueshift:android-sdk-x:$sdkVersion" | ||
## Depend on Firebase Messaging | ||
### Install Firebase Cloud Messaging | ||
@@ -19,3 +21,5 @@ Blueshift uses Firebase Messaging for sending push messages. If not already done, please integrate Firebase Messaging into the project. | ||
```xml | ||
<service android:name="com.blueshift.fcm.BlueshiftMessagingService"> | ||
<service | ||
android:name="com.blueshift.fcm.BlueshiftMessagingService" | ||
android:exported="true"> | ||
<intent-filter> | ||
@@ -56,3 +60,3 @@ <action android:name="com.google.firebase.MESSAGING_EVENT" /> | ||
## Grant Permissions | ||
### Permissions | ||
@@ -76,13 +80,20 @@ Add the following permissions to the `AndroidManifest.xml` file. | ||
## Initialize the Native SDK | ||
### Initialize the Native SDK | ||
Open the `MainApplication` class and add the following lines to its `onCreate()` method. | ||
Open the `MainApplication.java` file and import the following classes. | ||
```java | ||
import com.blueshift.model.Configuration; | ||
import com.blueshift.Blueshift; | ||
``` | ||
Now add the following lines inside the `onCreated()` method of `MainApplication` class to initialize the Blueshift SDK. | ||
```java | ||
Configuration configuration = new Configuration(); | ||
// Set Blueshift event API key | ||
configuration.setApiKey(YOUR_EVENT_API_KEY); | ||
// Set device-id source to Instance Id and package name combo (highly recommended) | ||
configuration.setDeviceIdSource(Blueshift.DeviceIdSource.INSTANCE_ID_PKG_NAME); | ||
// == Mandatory Settings == | ||
configuration.setAppIcon(R.mipmap.ic_launcher); | ||
configuration.setApiKey("BLUESHIFT_EVENT_API_KEY"); | ||
Blueshift.getInstance(this).initialize(configuration); | ||
@@ -93,9 +104,23 @@ ``` | ||
Also, add update the `onCreate()` and `onNewIntent()` methods of your `MainActivity` class as given below to handle push deep links. | ||
## 2. Push Notifications | ||
Push notifications are enabled by default. You should be able to receive push notifications by now if you have followed the steps mentioned above. | ||
To enable deeplinking from push notification, follow the below steps. | ||
Open the `MainActivity.java` file and import the following classes. | ||
```java | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import com.blueshift.reactnative.BlueshiftReactNativeModule; | ||
``` | ||
Now add the following code inside the `MainActivity` class to handle push notification deeplinks. | ||
```java | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
BlueshiftReactNativeModule.processBlueshiftPushUrl(getIntent()); | ||
super.onCreate(savedInstanceState); | ||
BlueshiftReactNativeModule.processBlueshiftPushUrl(getIntent()); | ||
} | ||
@@ -105,5 +130,135 @@ | ||
public void onNewIntent(Intent intent) { | ||
super.onNewIntent(intent); | ||
BlueshiftReactNativeModule.processBlueshiftPushUrl(getIntent()); | ||
super.onNewIntent(intent); | ||
BlueshiftReactNativeModule.processBlueshiftPushUrl(getIntent()); | ||
} | ||
``` | ||
## 3. In-app messaging | ||
By default, In-app messages are disabled in the SDK. You will need to enable it explicitly using the Blueshift config during SDK initialization. | ||
Add the following lines before calling the initialize method mentioned in the "Initialize the Native SDK" section above. | ||
```java | ||
// Enable in-app messages | ||
configuration.setInAppEnabled(true); | ||
configuration.setJavaScriptForInAppWebViewEnabled(true); | ||
``` | ||
By default, the time interval between two in-app messages is one minute. You can use the following method to change this interval during the SDK initialization. | ||
```java | ||
configuration.setInAppInterval(1000 * 60 * 2); // This will set the interval to two minutes. | ||
``` | ||
### In-app display options. | ||
The app must register/whitelist its pages/screens to show in-app messages. | ||
#### 1. Show on all pages | ||
To whitelist all pages/screens make use of `ActivityLifecycleCallback` as mentioned below. | ||
```java | ||
public class YourApplication extends Application implements Application.ActivityLifecycleCallbacks { | ||
@Override | ||
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) { | ||
} | ||
@Override | ||
public void onActivityStarted(@NonNull Activity activity) { | ||
Blueshift.getInstance(activity).registerForInAppMessages(activity); | ||
} | ||
@Override | ||
public void onActivityResumed(@NonNull Activity activity) { | ||
} | ||
@Override | ||
public void onActivityPaused(@NonNull Activity activity) { | ||
} | ||
@Override | ||
public void onActivityStopped(@NonNull Activity activity) { | ||
Blueshift.getInstance(activity).unregisterForInAppMessages(activity); | ||
} | ||
@Override | ||
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) { | ||
} | ||
@Override | ||
public void onActivityDestroyed(@NonNull Activity activity) { | ||
} | ||
} | ||
``` | ||
#### 2. Show on selected pages | ||
To register selected screens of the react native application, make use of the following methods in the respective callacks. | ||
```js | ||
componentDidMount() { | ||
// Register for in-app notification | ||
Blueshift.registerForInAppMessage("ScreenName"); | ||
} | ||
componentWillUnmount() { | ||
// Unregister for in-app notification | ||
Blueshift.unregisterForInAppMessage(); | ||
} | ||
``` | ||
## 4. Blueshift Deep Links | ||
Blueshift’s deep links are usual https URLs that take users to an installed app or a web browser to show the content. If an email or text message that we send as a part of a campaign contains Blueshift deep links and a user clicks on it, the OS will launch the installed app and Blueshift SDK will deliver the deep link to the app to navigate the user to the respective screen. | ||
To enable the domain verification, follow the steps mentioned in [this](https://developer.blueshift.com/docs/integrate-blueshifts-universal-links-android) document's **Prerequisite** section. | ||
To open the app when someone clicks the link, add the following intent filter to the `<activity>` tag for your `MainActivity` inside your `AndroidManifest.xml` file. Make sure to replace `links.clientdomain.com` with your email domain name. | ||
```xml | ||
<intent-filter | ||
android:autoVerify="true" | ||
tools:targetApi="m"> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
<data | ||
android:host="links.clientdomain.com" | ||
android:pathPrefix="/track" | ||
android:scheme="https" /> | ||
<data | ||
android:host="links.clientdomain.com" | ||
android:pathPrefix="/z" | ||
android:scheme="https" /> | ||
</intent-filter> | ||
``` | ||
## Logging | ||
To verify the SDK integration, enable the logging and see the events are being sent to the Blueshift APIs. | ||
Open the `MainActivity.java` file and import the following class. | ||
```java | ||
import com.blueshift.BlueshiftLogger; | ||
``` | ||
Now add the below lines before the SDK initialization code for enabling SDK logs. | ||
```java | ||
// Enable logging to view SDK logs in logcat window. | ||
if (BuildConfig.DEBUG) { | ||
// You must disable logging in production. | ||
BlueshiftLogger.setLogLevel(BlueshiftLogger.VERBOSE); | ||
} | ||
``` |
@@ -9,6 +9,6 @@ import React, {Component} from 'react'; | ||
componentDidMount() { | ||
// Read deeplinks when brought from killed state | ||
global.killedStateUrlListener = Linking.getInitialURL().then(url => { | ||
// Get the email deep link when app launched from killed state | ||
Linking.getInitialURL().then(url => { | ||
if(url) { | ||
// Check if the URL is a rewritten/shortened URL from Blueshift | ||
// Check if the email deep link is from Blueshift | ||
if (Blueshift.isBlueshiftUrl(url)) { | ||
@@ -22,3 +22,3 @@ Blueshift.processBlueshiftUrl(url); | ||
// Read deeplinks when app is alive | ||
// Add event listner for `url` event | ||
global.urlListener = Linking.addEventListener('url', (event) => { | ||
@@ -36,2 +36,3 @@ var url = event.url; | ||
// Add custom event listener using Blueshift method | ||
Blueshift.addEventListener('PushNotificationClickedEvent', this.handlePushClick); | ||
@@ -41,4 +42,3 @@ | ||
console.log("componentDidMount"); | ||
// Register screen for receiving in-app notifications | ||
this.registerForInApp(); | ||
@@ -48,9 +48,11 @@ } | ||
componentWillUnmount() { | ||
global.killedStateUrlListener.remove(); | ||
global.urlListener.remove(); | ||
// You must unregister these callbacks | ||
if (global) { | ||
global.urlListener.remove(); | ||
} | ||
// Remove custom event listner using Blueshift method | ||
Blueshift.removeEventListener('PushNotificationClickedEvent'); | ||
console.log("componentDidUnMount"); | ||
// Unregister screen | ||
this.unRegisterForInApp(); | ||
@@ -57,0 +59,0 @@ } |
@@ -13,3 +13,3 @@ { | ||
"dependencies": { | ||
"blueshift-react-native": "github:blueshift-labs/blueshift-react-native", | ||
"blueshift-react-native": "^1.0.0-beta.1", | ||
"react": "17.0.2", | ||
@@ -16,0 +16,0 @@ "react-native": "0.67.3" |
258
index.d.ts
declare module 'blueshift-react-native' { | ||
/** | ||
* Add event listener for a event name to listen to events fired by Blueshift SDK | ||
* | ||
* Usage - | ||
* Blueshift.addEventListener("PushNotificationClickedEvent", this.handlePush); | ||
* | ||
* @param {string} eventName Name of event to listen to. | ||
* @param {function} callback callback function to handle the event | ||
* | ||
* Usage - | ||
* Blueshift.addEventListener("PushNotificationClickedEvent", this.handlePush); | ||
* @param eventName | ||
* @param callback | ||
*/ | ||
@@ -18,7 +18,7 @@ function addEventListener(eventName : string, callback : any): void; | ||
* | ||
* Usage - | ||
* Blueshift.removeEventListener("PushNotificationClickedEvent"); | ||
* | ||
* @param {string} eventName Name of event remove the listener. | ||
* | ||
* Usage - | ||
* Blueshift.removeEventListener("PushNotificationClickedEvent"); | ||
* @param eventName | ||
*/ | ||
@@ -30,7 +30,7 @@ function removeEventListener(eventName : string): void; | ||
* | ||
* @param {String} screenName Name of the screen. | ||
* | ||
* Usage - | ||
* Blueshift.registerForInAppMessage("IndexScreen"); | ||
* @param screenName | ||
* | ||
* @param {string} screenName Name of the screen. | ||
* | ||
*/ | ||
@@ -67,7 +67,7 @@ function registerForInAppMessage(screenName : string): void; | ||
* | ||
* @param {Object} details Additional params (if any) | ||
* | ||
* Usage - | ||
* Blueshift.Blueshift.identifyWithDetails({}) | ||
* @param details | ||
* | ||
* @param {object} details Additional params (if any) | ||
* | ||
*/ | ||
@@ -79,11 +79,9 @@ function identifyWithDetails(details : any): void; | ||
* | ||
* @param {String} eventName Name of the custom event. | ||
* @param {Object} details Additional params (if any). | ||
* @param {Boolean} isBatch Tells if this event can be batched or not. | ||
* | ||
* Usage - | ||
* Blueshift.trackCustomEvent("CustomEvent",{},false); | ||
* @param eventName | ||
* @param details | ||
* @param isBatch | ||
* | ||
* @param {string} eventName Name of the custom event. | ||
* @param {object} details Additional params (if any). | ||
* @param {boolean} isBatch Tells if this event can be batched or not. | ||
* | ||
*/ | ||
@@ -95,11 +93,9 @@ function trackCustomEvent(eventName : string, details : any, isBatch : boolean): void; | ||
* | ||
* @param {String} screenName Name of the screen to track. | ||
* @param {Object} details Additional params (if any). | ||
* @param {Boolean} isBatch Tells if this event can be batched or not. | ||
* | ||
* Usage - | ||
* Blueshift.trackScreenView("IndexScreen",{},false); | ||
* @param screenName | ||
* @param details | ||
* @param isBatch | ||
* | ||
* @param {string} screenName Name of the screen to track. | ||
* @param {object} details Additional params (if any). | ||
* @param {boolean} isBatch Tells if this event can be batched or not. | ||
* | ||
*/ | ||
@@ -111,7 +107,7 @@ function trackScreenView(screenName : string, details : any, isBatch : boolean): void; | ||
* | ||
* @param {String} emailId email of the customer. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoEmailId("test@test.com"); | ||
* @param emailId | ||
* | ||
* @param {string} emailId email of the customer. | ||
* | ||
*/ | ||
@@ -123,7 +119,7 @@ function setUserInfoEmailId(emailId : string): void; | ||
* | ||
* @param {String} customerId customerId of the customer. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoCustomerId("cust123456"); | ||
* @param customerId | ||
* | ||
* @param {string} customerId customerId of the customer. | ||
* | ||
*/ | ||
@@ -135,7 +131,7 @@ function setUserInfoCustomerId(customerId : string): void; | ||
* | ||
* @param {String} firstname firstname of the customer. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoFirstName("John"); | ||
* @param firstname | ||
* | ||
* @param {string} firstname firstname of the customer. | ||
* | ||
*/ | ||
@@ -147,7 +143,7 @@ function setUserInfoFirstName(firstname : string): void; | ||
* | ||
* @param {String} lastname lastname of the customer. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoLastName("Cartor"); | ||
* @param lastname | ||
* | ||
* @param {string} lastname lastname of the customer. | ||
* | ||
*/ | ||
@@ -159,7 +155,7 @@ function setUserInfoLastName(lastname : string): void; | ||
* | ||
* @param {Object} extras additional user info. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoExtras({"profession":"software engineer", "usertype":"premium"}); | ||
* @param extras | ||
* | ||
* @param {object} extras additional user info. | ||
* | ||
*/ | ||
@@ -179,7 +175,7 @@ function setUserInfoExtras(extras : any): void; | ||
* | ||
* @param {Boolean} enabled When true, tracking is enabled. When false, disabled. | ||
* | ||
* Usage - | ||
* Blueshift.setEnableTracking(true); | ||
* @param enabled | ||
* | ||
* @param {boolean} enabled When true, tracking is enabled. When false, disabled. | ||
* | ||
*/ | ||
@@ -191,7 +187,7 @@ function setEnableTracking(enabled : boolean): void; | ||
* | ||
* @param {Boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
* Usage - | ||
* Blueshift.setEnablePush(true); | ||
* @param isEnabled | ||
* | ||
* @param {boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
*/ | ||
@@ -203,7 +199,7 @@ function setEnablePush(isEnabled : boolean): void; | ||
* | ||
* @param {Boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
* Usage - | ||
* Blueshift.setEnableInApp(true); | ||
* @param isEnabled | ||
* | ||
* @param {boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
*/ | ||
@@ -216,7 +212,7 @@ function setEnableInApp(isEnabled : boolean): void; | ||
* | ||
* @param {String} IDFAString IDFA value. | ||
* | ||
* Usage - | ||
* Blueshift.setIDFA("EA7583CD-A667-48BC-B806-42ECB2B48606"); | ||
* @param IDFAString | ||
* | ||
* @param {string} IDFAString IDFA value. | ||
* | ||
*/ | ||
@@ -238,9 +234,8 @@ function setIDFA(IDFAString : string): void; | ||
* | ||
* Usage - | ||
* Blueshift.setCurrentLocation(18.5245649,73.7228812); | ||
* | ||
* @param {Number} latitude location latitude value. | ||
* @param {Number} longitude location longitude value. | ||
* | ||
* Usage - | ||
* Blueshift.setCurrentLocation(18.5245649,73.7228812); | ||
* @param latitude | ||
* @param longitude | ||
*/ | ||
@@ -252,8 +247,4 @@ function setCurrentLocation(latitude : number, longitude : number): void; | ||
* | ||
* @param {String} slot slot name of the live content. | ||
* @param {Object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
* Usage - | ||
* Blueshift.getLiveContentByEmail("testSlot",{},(err,result) => { | ||
* Blueshift.getLiveContentByEmail("testSlot",{},(err:any,result:any) => { | ||
* if (result) { | ||
@@ -265,7 +256,9 @@ * console.log(result); | ||
* }); | ||
* @param slot | ||
* @param lcContext | ||
* @param callback | ||
* | ||
* @param {string} slot slot name of the live content. | ||
* @param {object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
*/ | ||
function getLiveContentByEmail(slot : string, lcContext : any, callback : any): void; | ||
function getLiveContentByEmail(slot : string, lcContext : any, callback : function): void; | ||
@@ -275,8 +268,4 @@ /** | ||
* | ||
* @param {String} slot slot name of the live content. | ||
* @param {Object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
* Usage - | ||
* Blueshift.getLiveContentByCustomerId("testSlot",{},(err,result) => { | ||
* Blueshift.getLiveContentByCustomerId("testSlot",{},(err:any,result:any) => { | ||
* if (result) { | ||
@@ -288,7 +277,9 @@ * console.log(result); | ||
* }); | ||
* @param slot | ||
* @param lcContext | ||
* @param callback | ||
* | ||
* @param {string} slot slot name of the live content. | ||
* @param {object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
*/ | ||
function getLiveContentByCustomerId(slot : string, lcContext : any, callback : any): void; | ||
function getLiveContentByCustomerId(slot : string, lcContext : any, callback : function): void; | ||
@@ -298,8 +289,4 @@ /** | ||
* | ||
* @param {String} slot slot name of the live content. | ||
* @param {Object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
* Usage - | ||
* Blueshift.getLiveContentByDeviceId("testSlot",{},(err,result) => { | ||
* Blueshift.getLiveContentByDeviceId("testSlot",{}(err:any,result:any) => { | ||
* if (result) { | ||
@@ -311,7 +298,9 @@ * console.log(result); | ||
* }); | ||
* @param slot | ||
* @param lcContext | ||
* @param callback | ||
* | ||
* @param {string} slot slot name of the live content. | ||
* @param {object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
*/ | ||
function getLiveContentByDeviceId(slot : string, lcContext : any, callback : any): void; | ||
function getLiveContentByDeviceId(slot : string, lcContext : any, callback : function): void; | ||
@@ -321,11 +310,11 @@ /** | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
* Blueshift.getEnableInAppStatus((value) => { | ||
* Blueshift.getEnableInAppStatus((value: boolean) => { | ||
* console.log("status"+value); | ||
* }); | ||
* @param callback | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
function getEnableInAppStatus(callback : any): void; | ||
function getEnableInAppStatus(callback : function): void; | ||
@@ -335,11 +324,11 @@ /** | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
* Blueshift.getEnablePushStatus((value) => { | ||
* Blueshift.getEnablePushStatus((value: boolean) => { | ||
* console.log("status"+value); | ||
* }); | ||
* @param callback | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
function getEnablePushStatus(callback : any): void; | ||
function getEnablePushStatus(callback : function): void; | ||
@@ -349,11 +338,11 @@ /** | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
* Blueshift.getEnableTrackingStatus((value) => { | ||
* Blueshift.getEnableTrackingStatus((value: boolean) => { | ||
* console.log("status"+value); | ||
* }); | ||
* @param callback | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
function getEnableTrackingStatus(callback : any): void; | ||
function getEnableTrackingStatus(callback : function): void; | ||
@@ -363,11 +352,11 @@ /** | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoEmailId((value) => { | ||
* Blueshift.getUserInfoEmailId((value: string) => { | ||
* console.log("Email id"+value); | ||
* }); | ||
* @param callback | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
function getUserInfoEmailId(callback : any): void; | ||
function getUserInfoEmailId(callback : function): void; | ||
@@ -377,11 +366,11 @@ /** | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoCustomerId((value) => { | ||
* Blueshift.getUserInfoCustomerId((value: string) => { | ||
* console.log("Customer id"+value); | ||
* }); | ||
* @param callback | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
function getUserInfoCustomerId(callback : any): void; | ||
function getUserInfoCustomerId(callback : function): void; | ||
@@ -391,11 +380,11 @@ /** | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoFirstName((value) => { | ||
* Blueshift.getUserInfoFirstName((value: string) => { | ||
* console.log("First name"+value); | ||
* }); | ||
* @param callback | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
function getUserInfoFirstName(callback : any): void; | ||
function getUserInfoFirstName(callback : function): void; | ||
@@ -405,11 +394,11 @@ /** | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoLastName((value) => { | ||
* Blueshift.getUserInfoLastName((value: string) => { | ||
* console.log("Last name"+value); | ||
* }); | ||
* @param callback | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
function getUserInfoLastName(callback : any): void; | ||
function getUserInfoLastName(callback : function): void; | ||
@@ -419,11 +408,11 @@ /** | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoExtras((value) => { | ||
* Blueshift.getUserInfoExtras((value: any) => { | ||
* console.log("Extras"+value); | ||
* }); | ||
* @param callback | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
function getUserInfoExtras(callback : any): void; | ||
function getUserInfoExtras(callback : function): void; | ||
@@ -433,11 +422,11 @@ /** | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
* Blueshift.getCurrentDeviceId((value) => { | ||
* Blueshift.getCurrentDeviceId((value: string) => { | ||
* console.log("Device id"+value); | ||
* }); | ||
* @param callback | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
function getCurrentDeviceId(callback : any): void; | ||
function getCurrentDeviceId(callback : function): void; | ||
@@ -447,4 +436,4 @@ /** | ||
* | ||
* @param {String} url | ||
* @param url | ||
* @param {string} url | ||
* | ||
*/ | ||
@@ -456,7 +445,6 @@ function processBlueshiftUrl(url : string): void; | ||
* | ||
* @param {String} url | ||
* @param url | ||
* @return | ||
* @param {string} url | ||
* @return {boolean} | ||
*/ | ||
function isBlueshiftUrl(url : string): boolean; | ||
} |
165
index.js
@@ -10,8 +10,8 @@ import { DeviceEventEmitter, Linking, NativeEventEmitter, NativeModules, Platform } from 'react-native'; | ||
* | ||
* @param {string} eventName Name of event to listen to. | ||
* @param {function} callback callback function to handle the event | ||
* | ||
* Usage - | ||
* Blueshift.addEventListener("PushNotificationClickedEvent", this.handlePush); | ||
* | ||
* @param {string} eventName Name of event to listen to. | ||
* @param {function} callback callback function to handle the event | ||
* | ||
*/ | ||
@@ -31,7 +31,7 @@ addEventListener: function(eventName, callback) { | ||
* | ||
* @param {string} eventName Name of event remove the listener. | ||
* | ||
* Usage - | ||
* Blueshift.removeEventListener("PushNotificationClickedEvent"); | ||
* | ||
* @param {string} eventName Name of event remove the listener. | ||
* | ||
*/ | ||
@@ -47,7 +47,7 @@ removeEventListener: function(eventName) { | ||
* | ||
* @param {String} screenName Name of the screen. | ||
* | ||
* Usage - | ||
* Blueshift.registerForInAppMessage("IndexScreen"); | ||
* | ||
* @param {string} screenName Name of the screen. | ||
* | ||
*/ | ||
@@ -97,7 +97,7 @@ registerForInAppMessage: function(screenName) { | ||
* | ||
* @param {Object} details Additional params (if any) | ||
* | ||
* Usage - | ||
* Blueshift.Blueshift.identifyWithDetails({}) | ||
* | ||
* @param {object} details Additional params (if any) | ||
* | ||
*/ | ||
@@ -112,9 +112,9 @@ | ||
* | ||
* @param {String} eventName Name of the custom event. | ||
* @param {Object} details Additional params (if any). | ||
* @param {Boolean} isBatch Tells if this event can be batched or not. | ||
* | ||
* Usage - | ||
* Blueshift.trackCustomEvent("CustomEvent",{},false); | ||
* | ||
* @param {string} eventName Name of the custom event. | ||
* @param {object} details Additional params (if any). | ||
* @param {boolean} isBatch Tells if this event can be batched or not. | ||
* | ||
*/ | ||
@@ -129,9 +129,9 @@ | ||
* | ||
* @param {String} screenName Name of the screen to track. | ||
* @param {Object} details Additional params (if any). | ||
* @param {Boolean} isBatch Tells if this event can be batched or not. | ||
* | ||
* Usage - | ||
* Blueshift.trackScreenView("IndexScreen",{},false); | ||
* | ||
* @param {string} screenName Name of the screen to track. | ||
* @param {object} details Additional params (if any). | ||
* @param {boolean} isBatch Tells if this event can be batched or not. | ||
* | ||
*/ | ||
@@ -146,7 +146,7 @@ trackScreenView: function(screenName, details, isBatch) { | ||
* | ||
* @param {String} emailId email of the customer. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoEmailId("test@test.com"); | ||
* | ||
* @param {string} emailId email of the customer. | ||
* | ||
*/ | ||
@@ -160,8 +160,8 @@ | ||
* Save customerId in the SDK. | ||
* | ||
* @param {String} customerId customerId of the customer. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoCustomerId("cust123456"); | ||
* | ||
* | ||
* @param {string} customerId customerId of the customer. | ||
* | ||
*/ | ||
@@ -175,7 +175,7 @@ | ||
* Save firstname in the SDK. | ||
* | ||
* @param {String} firstname firstname of the customer. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoFirstName("John"); | ||
* | ||
* @param {string} firstname firstname of the customer. | ||
* | ||
@@ -190,6 +190,6 @@ */ | ||
* | ||
* @param {String} lastname lastname of the customer. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoLastName("Cartor"); | ||
* | ||
* @param {string} lastname lastname of the customer. | ||
* | ||
@@ -203,7 +203,7 @@ */ | ||
* Save additional user info in the SDK. | ||
* | ||
* @param {Object} extras additional user info. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoExtras({"profession":"software engineer", "usertype":"premium"}); | ||
* | ||
* @param {object} extras additional user info. | ||
* | ||
@@ -228,10 +228,10 @@ */ | ||
* Enable/disable SDK's event tracking. | ||
* | ||
* @param {Boolean} enabled When true, tracking is enabled. When false, disabled. | ||
* | ||
* Usage - | ||
* Blueshift.setEnableTracking(true); | ||
* | ||
* @param {boolean} enabled When true, tracking is enabled. When false, disabled. | ||
* | ||
*/ | ||
setEnableTracking: function(enabled) { | ||
setEnableTracking: function(enabled) { | ||
NativeModules.BlueshiftBridge.setEnableTracking(enabled); | ||
@@ -242,8 +242,8 @@ }, | ||
* Opt-in or opt-out of push notifications sent from Blueshift. | ||
* | ||
* @param {Boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
* Usage - | ||
* Blueshift.setEnablePush(true); | ||
* | ||
* | ||
* @param {boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
*/ | ||
@@ -257,9 +257,8 @@ setEnablePush: function(isEnabled) { | ||
* | ||
* @param {Boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
* Usage - | ||
* Blueshift.setEnableInApp(true); | ||
* | ||
* @param {boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
*/ | ||
setEnableInApp: function(isEnabled) { | ||
@@ -273,7 +272,7 @@ NativeModules.BlueshiftBridge.setEnableInApp(isEnabled); | ||
* | ||
* @param {String} IDFAString IDFA value. | ||
* | ||
* Usage - | ||
* Blueshift.setIDFA("EA7583CD-A667-48BC-B806-42ECB2B48606"); | ||
* | ||
* @param {string} IDFAString IDFA value. | ||
* | ||
*/ | ||
@@ -294,3 +293,2 @@ setIDFA: function(IDFAString) { | ||
*/ | ||
registerForRemoteNotification: function() { | ||
@@ -306,8 +304,8 @@ if (Platform.OS === 'ios') { | ||
* | ||
* Usage - | ||
* Blueshift.setCurrentLocation(18.5245649,73.7228812); | ||
* | ||
* @param {Number} latitude location latitude value. | ||
* @param {Number} longitude location longitude value. | ||
* | ||
* Usage - | ||
* Blueshift.setCurrentLocation(18.5245649,73.7228812); | ||
* | ||
*/ | ||
@@ -322,6 +320,2 @@ setCurrentLocation: function(latitude, longitude) { | ||
* Calls Blueshift's live content API with email and given slot name and live content context. | ||
* | ||
* @param {String} slot slot name of the live content. | ||
* @param {Object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
@@ -336,2 +330,7 @@ * Usage - | ||
* }); | ||
* | ||
* @param {string} slot slot name of the live content. | ||
* @param {object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
*/ | ||
@@ -344,6 +343,2 @@ getLiveContentByEmail: function(slot, lcContext, callback) { | ||
* Calls Blueshift's live content API with customer id and given slot name and live content context. | ||
* | ||
* @param {String} slot slot name of the live content. | ||
* @param {Object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
@@ -358,2 +353,7 @@ * Usage - | ||
* }); | ||
* | ||
* @param {string} slot slot name of the live content. | ||
* @param {object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
*/ | ||
@@ -366,6 +366,2 @@ getLiveContentByCustomerId: function(slot, lcContext, callback) { | ||
* Calls Blueshift's live content API with device id and given slot name and live content context. | ||
* | ||
* @param {String} slot slot name of the live content. | ||
* @param {Object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
@@ -380,4 +376,9 @@ * Usage - | ||
* }); | ||
* | ||
* @param {string} slot slot name of the live content. | ||
* @param {object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
*/ | ||
getLiveContentByDeviceId: function(slot, lcContext, callback) { | ||
getLiveContentByDeviceId: function(slot, lcContext, callback) { | ||
NativeModules.BlueshiftBridge.getLiveContentByDeviceId(slot,lcContext,callback); | ||
@@ -389,4 +390,2 @@ }, | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
@@ -396,2 +395,5 @@ * Blueshift.getEnableInAppStatus((value) => { | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
@@ -405,4 +407,2 @@ getEnableInAppStatus: function(callback) { | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
@@ -412,2 +412,5 @@ * Blueshift.getEnablePushStatus((value) => { | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
@@ -421,4 +424,2 @@ getEnablePushStatus: function(callback) { | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
@@ -428,2 +429,5 @@ * Blueshift.getEnableTrackingStatus((value) => { | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
@@ -437,4 +441,2 @@ getEnableTrackingStatus: function(callback) { | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
@@ -444,2 +446,5 @@ * Blueshift.getUserInfoEmailId((value) => { | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
@@ -453,4 +458,2 @@ getUserInfoEmailId: function(callback) { | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
@@ -460,2 +463,5 @@ * Blueshift.getUserInfoCustomerId((value) => { | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
@@ -469,4 +475,2 @@ getUserInfoCustomerId: function(callback) { | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
@@ -476,2 +480,5 @@ * Blueshift.getUserInfoFirstName((value) => { | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
@@ -485,4 +492,2 @@ getUserInfoFirstName: function(callback) { | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
@@ -492,2 +497,5 @@ * Blueshift.getUserInfoLastName((value) => { | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
@@ -501,4 +509,2 @@ getUserInfoLastName: function(callback) { | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
@@ -508,2 +514,5 @@ * Blueshift.getUserInfoExtras((value) => { | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
@@ -517,4 +526,2 @@ getUserInfoExtras: function(callback) { | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
* Usage - | ||
@@ -524,2 +531,5 @@ * Blueshift.getCurrentDeviceId((value) => { | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
@@ -530,6 +540,7 @@ getCurrentDeviceId: function(callback) { | ||
/** | ||
/** | ||
* Process the Blueshift url and provide the final url to Linking's "url" callback | ||
* | ||
* @param {String} url | ||
* @param {string} url | ||
* | ||
*/ | ||
@@ -545,3 +556,3 @@ processBlueshiftUrl: function(url) { | ||
* | ||
* @param {String} url | ||
* @param {string} url | ||
*/ | ||
@@ -548,0 +559,0 @@ isBlueshiftUrl: function(url) { |
13
iOS.md
@@ -58,4 +58,4 @@ # iOS Plugin Integration | ||
// Delay push permission by setting NO, by default push permission is displayed on app launch. | ||
config.enablePushNotification = NO; | ||
// Delay push permission dialog by setting NO, by default push permission dialog is displayed on app launch. | ||
config.enablePushNotification = YES; | ||
@@ -121,9 +121,6 @@ // Set userNotificationDelegate to self to get the push notification callbacks. | ||
// Optional: Set the applications launch Options for SDK to track. | ||
[config setApplicationLaunchOptions:launchOptions]; | ||
``` | ||
The SDK setup with automatic integration is complete over here. Using this setup you will be able to send events to Blueshift, send basic push notifications (title+content) to the iOS device. And also you will get the deep links in your react app using event `url`. | ||
Refer section to enable Rich push notifications, section to enable in-app notifications and section to enable Blueshift email deep links. | ||
The SDK setup with automatic integration is complete over here. Using this setup you will be able to send events to Blueshift, send basic push notifications (title+content) to the iOS device. And also you will get the push notification deep links in your react app using event `url`. | ||
Refer [section](#2-enable-rich-push-notifications) to enable Rich push notifications, [section](#3-enable-in-app-messages) to enable in-app notifications and [section](#4-enable-blueshift-email-deep-links) to enable Blueshift email deep links. | ||
@@ -269,3 +266,3 @@ | ||
``` | ||
## 3. Enable Blueshift email deep links | ||
## 4. Enable Blueshift email deep links | ||
Blueshift’s deep links are usual https URLs that take users to a page in the app or launch them in a browser. If an email or text message that we send as a part of your campaign contains a Blueshift deep link and a user clicks on it, iOS will launch the installed app and Blueshift SDK will deliver the deep link to the app so that app can navigate the user to the respective screen. | ||
@@ -272,0 +269,0 @@ |
{ | ||
"name": "blueshift-react-native", | ||
"version": "1.0.0-beta.1", | ||
"version": "1.0.0", | ||
"description": "React native plugin for Blueshift iOS and Android SDK.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1754848
1