blueshift-react-native
Advanced tools
Comparing version 1.0.3 to 1.1.0
module.exports = { | ||
bracketSpacing: false, | ||
jsxBracketSameLine: true, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
arrowParens: 'avoid', | ||
}; |
@@ -1,540 +0,27 @@ | ||
import React, {Component} from 'react'; | ||
import {Dimensions, StyleSheet, Text,Switch, View, TextInput, SafeAreaView, ScrollView, NativeModules, Button, Alert, Platform, Linking} from 'react-native'; | ||
import {NavigationContainer} from "@react-navigation/native"; | ||
import {createNativeStackNavigator} from "@react-navigation/native-stack"; | ||
import HomeScreen from "./Homescreen"; | ||
import InboxScreen from "./Inboxscreen"; | ||
import DeeplinkScreen from "./Deeplinkscreen"; | ||
import {Button} from "react-native"; | ||
import React from "react"; | ||
import Blueshift from 'blueshift-react-native'; | ||
const Stack = createNativeStackNavigator(); | ||
export default class App extends Component { | ||
componentDidMount() { | ||
// Get the email deep link when app launched from killed state | ||
Linking.getInitialURL().then(url => { | ||
if(url) { | ||
// Check if the email deep link is from Blueshift | ||
if (Blueshift.isBlueshiftUrl(url)) { | ||
Blueshift.processBlueshiftUrl(url); | ||
} else { | ||
this.handleDeeplinkUrl(url); | ||
} | ||
} | ||
}); | ||
// Add event listner for `url` event | ||
global.urlListener = Linking.addEventListener('url', (event) => { | ||
var url = event.url; | ||
if(url) { | ||
// Check if the URL is a rewritten/shortened URL from Blueshift | ||
if (Blueshift.isBlueshiftUrl(url)) { | ||
Blueshift.processBlueshiftUrl(url); | ||
} else { | ||
this.handleDeeplinkUrl(url); | ||
} | ||
} | ||
}); | ||
Blueshift.init(); | ||
// Add custom event listener using Blueshift method | ||
Blueshift.addEventListener('PushNotificationClickedEvent', this.handlePushClick); | ||
this.setValues(); | ||
// Register screen for receiving in-app notifications | ||
this.registerForInApp(); | ||
} | ||
componentWillUnmount() { | ||
// You must unregister these callbacks | ||
if (global) { | ||
global.urlListener.remove(); | ||
} | ||
// Remove custom event listner using Blueshift method | ||
Blueshift.removeEventListener('PushNotificationClickedEvent'); | ||
// Unregister screen | ||
this.unRegisterForInApp(); | ||
} | ||
handlePushClick = (event) => { | ||
alert("push payload "+JSON.stringify(event.bsft_experiment_uuid)); | ||
}; | ||
handleDeeplinkUrl(url) { | ||
console.log("deeplink: " + url); | ||
Alert.alert( | ||
"Deep Link URL", | ||
url, | ||
[ | ||
{ | ||
text: "Cancel", | ||
onPress: () => console.log("Cancel Pressed"), | ||
style: "cancel" | ||
}, | ||
{ text: "OK", onPress: () => console.log("OK Pressed") } | ||
] | ||
export default function App() { | ||
return ( | ||
<NavigationContainer> | ||
<Stack.Navigator> | ||
<Stack.Screen | ||
name="Home" | ||
component={HomeScreen} | ||
options={({navigation, route}) => ({ | ||
title: "Blueshift Sample App", | ||
})} | ||
/> | ||
<Stack.Screen name="Inbox" component={InboxScreen} /> | ||
<Stack.Screen name="Deeplink" component={DeeplinkScreen} /> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
); | ||
}; | ||
setEmailId = () => { | ||
Blueshift.setUserInfoEmailId(this.state.emailId) | ||
}; | ||
setCustomerId = () => { | ||
Blueshift.setUserInfoCustomerId(this.state.customerId) | ||
}; | ||
setFirstName = () => { | ||
Blueshift.setUserInfoFirstName(this.state.firstName) | ||
}; | ||
setLastName = () => { | ||
Blueshift.setUserInfoLastName(this.state.lastName) | ||
}; | ||
setExtras = () => { | ||
Blueshift.setUserInfoExtras({"profession": "software engineer", "usertype":"premium"}) | ||
}; | ||
setIDFA = () => { | ||
Blueshift.setIDFA("EA7583CD-A667-48BC-B806-42ECB2B48606") | ||
}; | ||
setLocation = () => { | ||
Blueshift.setCurrentLocation(18.5245649,73.7228812) | ||
}; | ||
identify = () => { | ||
Blueshift.identifyWithDetails({}) | ||
}; | ||
sendCustomEvent = () => { | ||
Blueshift.trackCustomEvent(this.state.customEvent,{},false) | ||
}; | ||
sendCustomEvent1 = () => { | ||
Blueshift.trackCustomEvent(this.state.customEvent1,{},false) | ||
}; | ||
trackScreenView = () => { | ||
Blueshift.trackScreenView("ReactNativeTestScreen",{},false) | ||
}; | ||
removeUserInfo = () => { | ||
Blueshift.removeUserInfo() | ||
}; | ||
registerForRemoteNotification = () => { | ||
Blueshift.registerForRemoteNotification() | ||
}; | ||
setEnablePush = () => { | ||
Blueshift.setEnablePush(this.state.enablePushSwitchValue) | ||
}; | ||
setEnableInApp = () => { | ||
Blueshift.setEnableInApp(this.state.enableInAppSwitchValue) | ||
}; | ||
setEnableTracking = () => { | ||
Blueshift.setEnableTracking(this.state.enableTrackingSwitchValue) | ||
} | ||
fetchInAppNotification = () => { | ||
Blueshift.fetchInAppNotification() | ||
}; | ||
displayInAppNotification = () => { | ||
Blueshift.displayInAppNotification() | ||
}; | ||
registerForInApp = () => { | ||
Blueshift.registerForInAppMessage("index") | ||
}; | ||
unRegisterForInApp = () => { | ||
Blueshift.unregisterForInAppMessage() | ||
}; | ||
getLiveContentByEmail = () => { | ||
Blueshift.getLiveContentByEmail("careinappmessagingslot",{},(err,result) => { | ||
if (result != null) { | ||
console.log(result); | ||
} else { | ||
console.log(err); | ||
} | ||
}); | ||
}; | ||
getLiveContentByDeviceID = () => { | ||
Blueshift.getLiveContentByDeviceId("careinappmessagingslot",{},(err,result) => { | ||
if (result != null) { | ||
console.log(result); | ||
} else { | ||
console.log(err); | ||
} | ||
}); | ||
}; | ||
getLiveContentByCustomerID = () => { | ||
Blueshift.getLiveContentByCustomerId("careinappmessagingslot",{},(err,result) => { | ||
if (result != null) { | ||
console.log(result); | ||
} else { | ||
console.log(err); | ||
} | ||
}); | ||
}; | ||
state = { | ||
enablePushSwitchValue: true, | ||
enableInAppSwitchValue: true, | ||
enableTrackingSwitchValue: true, | ||
emailId: "", | ||
customEvent: "bsft_send_me_image_push", | ||
customEvent1: "bsft_send_me_in_app_modal", | ||
customerId: "", | ||
firstName: "", | ||
lastName: "", | ||
deviceId: "" | ||
}; | ||
setValues = () => { | ||
console.log("setValues"); | ||
Blueshift.getEnablePushStatus((res) => { | ||
this.setState({enablePushSwitchValue:res}); | ||
}); | ||
Blueshift.getEnableInAppStatus((res) => { | ||
this.setState({enableInAppSwitchValue:res}); | ||
}); | ||
Blueshift.getUserInfoCustomerId((res) => { | ||
this.setState({customerId:res}); | ||
}); | ||
Blueshift.getUserInfoEmailId((res) => { | ||
console.log("email",res); | ||
this.setState({emailId:res}); | ||
}); | ||
Blueshift.getEnableTrackingStatus((res) => { | ||
this.setState({enableTrackingSwitchValue:res}); | ||
}); | ||
Blueshift.getUserInfoFirstName((res) => { | ||
this.setState({firstName:res}); | ||
}); | ||
Blueshift.getUserInfoLastName((res) => { | ||
this.setState({lastName:res}); | ||
}); | ||
Blueshift.getCurrentDeviceId((res) => { | ||
console.log("deviceid",res); | ||
this.setState({deviceId:res}); | ||
}); | ||
}; | ||
render() { | ||
let w = Dimensions.get('window').width; | ||
let btnClr = "#2160D4" | ||
return ( | ||
<SafeAreaView style={styles.container}> | ||
<ScrollView style={{ width:w }} > | ||
<TextInput | ||
style={styles.txtStyle} | ||
onChangeText={(emailId)=>this.setState({emailId})} | ||
value={this.state.emailId} placeholder="Enter email id" /> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.setEmailId} | ||
title="Set email Id" | ||
color={btnClr} /> | ||
</View> | ||
<TextInput | ||
style={styles.txtStyle} | ||
onChangeText={(customerId)=>this.setState({customerId})} | ||
value={this.state.customerId} placeholder="Enter customer profile Id" /> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.setCustomerId} | ||
title="Set customer Id" | ||
color={btnClr} /> | ||
</View> | ||
<TextInput | ||
style={styles.txtStyle} | ||
onChangeText={(firstName)=>this.setState({firstName})} | ||
value={this.state.firstName} placeholder="Enter firstName" /> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.setFirstName} | ||
title="Set firstName" | ||
color={btnClr} /> | ||
</View> | ||
<TextInput | ||
style={styles.txtStyle} | ||
onChangeText={(lastName)=>this.setState({lastName})} | ||
value={this.state.lastName} placeholder="Enter lastName" /> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.setLastName} | ||
title="Set lastName" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.setExtras} | ||
title="Set extras" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.setIDFA} | ||
title="Set IDFA" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.setLocation} | ||
title="Set Location" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.identify} | ||
title="Identify" | ||
color={btnClr} /> | ||
</View> | ||
<TextInput | ||
style={styles.txtStyle} | ||
onChangeText={(customEvent)=>this.setState({customEvent})} | ||
value={this.state.customEvent} placeholder="Enter custom event name" /> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.sendCustomEvent} | ||
title="Send custom event" | ||
color={btnClr} /> | ||
</View> | ||
<TextInput | ||
style={styles.txtStyle} | ||
onChangeText={(customEvent1)=>this.setState({customEvent1})} | ||
value={this.state.customEvent1} placeholder="Enter custom event name" /> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.sendCustomEvent1} | ||
title="Send custom event" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.trackScreenView} | ||
title="Track screen view" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.registerForRemoteNotification} | ||
title="register for remote notifications" | ||
color={btnClr} /> | ||
</View> | ||
<View style={{ flexDirection: 'row'}}> | ||
<Switch | ||
style={{flex:1}} | ||
value={this.state.enablePushSwitchValue} | ||
onValueChange ={(enablePushSwitchValue)=>this.setState({enablePushSwitchValue})}/> | ||
<View style={[styles.btnStyle, {flex: 2}]}> | ||
<Button | ||
onPress={this.setEnablePush} | ||
title="Set enablePush" | ||
color={btnClr} /> | ||
</View> | ||
</View> | ||
<View style={{ flexDirection: 'row'}}> | ||
<Switch | ||
style={{flex:1}} | ||
value={this.state.enableInAppSwitchValue} | ||
onValueChange ={(enableInAppSwitchValue)=>this.setState({enableInAppSwitchValue})}/> | ||
<View style={[styles.btnStyle, {flex: 2}]}> | ||
<Button | ||
onPress={this.setEnableInApp} | ||
title="Set enableInApp" | ||
color={btnClr} /> | ||
</View> | ||
</View> | ||
<View style={{ flexDirection: 'row'}}> | ||
<Switch | ||
style={{flex:1}} | ||
value={this.state.enableTrackingSwitchValue} | ||
onValueChange ={(enableTrackingSwitchValue)=>this.setState({enableTrackingSwitchValue})}/> | ||
<View style={[styles.btnStyle, {flex: 2}]}> | ||
<Button | ||
onPress={this.setEnableTracking} | ||
title="Set enableTracking" | ||
color={btnClr} /> | ||
</View> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.fetchInAppNotification} | ||
title="fetch InApp Notification notifications" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.displayInAppNotification} | ||
title="display In App Notification" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.removeUserInfo} | ||
title="Remove user info" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.registerForInApp} | ||
title="Register For in-app notifications" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.unRegisterForInApp} | ||
title="Un-register for in-app notifications" | ||
color={btnClr} /> | ||
</View> | ||
<Text style={styles.txtH1Style}>{"Current Device ID"}</Text> | ||
<TextInput | ||
style={styles.txtStyle} | ||
onChangeText={(deviceId)=>this.setState({deviceId})} | ||
value={this.state.deviceId} /> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.getLiveContentByEmail} | ||
title="Live content by Email" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.getLiveContentByDeviceID} | ||
title="Live content by Device id" | ||
color={btnClr} /> | ||
</View> | ||
<View style={styles.btnStyle}> | ||
<Button | ||
onPress={this.getLiveContentByCustomerID} | ||
title="Live content by Customer id" | ||
color={btnClr} /> | ||
</View> | ||
</ScrollView> | ||
</SafeAreaView> | ||
); | ||
} | ||
} | ||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: '#F5FCFF', | ||
}, | ||
welcome: { | ||
flex: 1, | ||
borderColor: "#cccccc", | ||
borderBottomWidth: 1, | ||
marginBottom: 10 | ||
}, | ||
txtH1Style: { | ||
flex:1, | ||
marginLeft: 16, | ||
marginRight: 16, | ||
marginTop: 4, | ||
marginBottom: 4, | ||
padding: 8, | ||
}, | ||
txtStyle: { | ||
flex:1, | ||
height: 48, | ||
borderColor: '#2160D4', | ||
borderWidth: 1, | ||
marginLeft: 16, | ||
marginRight: 16, | ||
marginTop: 4, | ||
marginBottom: 4, | ||
padding: 8, | ||
}, | ||
btnStyle: { | ||
flex:1, | ||
marginLeft: 16, | ||
marginRight: 16, | ||
marginTop: 4, | ||
marginBottom: 4, | ||
} | ||
}); | ||
// import React, { useEffect } from 'react'; | ||
// const Root = () => { | ||
// Blueshift.identifyWithDetails({}); | ||
// useEffect(() => { | ||
// console.log('useEffect: START'); | ||
// // Add event listner for `url` event | ||
// global.urlListener = Linking.addEventListener('url', (event) => { | ||
// var url = event.url; | ||
// if(url) { | ||
// // Check if the URL is a rewritten/shortened URL from Blueshift | ||
// if (Blueshift.isBlueshiftUrl(url)) { | ||
// Blueshift.processBlueshiftUrl(url); | ||
// } else { | ||
// console.log('handleDeeplink: ' + url); | ||
// // this.handleDeeplinkUrl(url); | ||
// } | ||
// } | ||
// }); | ||
// Blueshift.addEventListener('PushNotificationClickedEvent', () =>{}); | ||
// return () => { | ||
// console.log('useEffect: return'); | ||
// global.urlListener.remove(); | ||
// } | ||
// }, []) | ||
// return ( | ||
// <View style={{ flex: 1 }}> | ||
// <Text>Hello</Text> | ||
// </View> | ||
// ); | ||
// } | ||
// export default Root; |
@@ -13,5 +13,10 @@ { | ||
"dependencies": { | ||
"blueshift-react-native": "file:..", | ||
"@react-navigation/native": "^6.1.6", | ||
"@react-navigation/native-stack": "^6.9.12", | ||
"blueshift-react-native": "git+https://github.com/blueshift-labs/blueshift-react-native.git#feature/inbox", | ||
"react": "^18.2.0", | ||
"react-native": "0.70.5" | ||
"react-native": "0.70.5", | ||
"react-native-safe-area-context": "^4.6.3", | ||
"react-native-screens": "^3.21.1", | ||
"save": "^2.9.0" | ||
}, | ||
@@ -26,3 +31,4 @@ "devDependencies": { | ||
"metro-react-native-babel-preset": "^0.69.0", | ||
"react-test-renderer": "17.0.2" | ||
"react-test-renderer": "17.0.2", | ||
"typescript": "^5.1.3" | ||
}, | ||
@@ -29,0 +35,0 @@ "jest": { |
@@ -46,2 +46,13 @@ declare module 'blueshift-react-native' { | ||
/** | ||
* Get registered screen name for in-app messages. | ||
* | ||
* Usage - | ||
* Blueshift.getRegisteredForInAppScreenName(screenName = { | ||
* console.log("registered screen name - " + screenName); | ||
* }); | ||
* | ||
*/ | ||
function getRegisteredForInAppScreenName(callback : function): void; | ||
/** | ||
* Unregisters a page from showing in-app message. | ||
@@ -411,4 +422,67 @@ * | ||
function getCurrentDeviceId(callback : function): void; | ||
/** | ||
* Reset the current device id. This is only applicable if the device id | ||
* source is set to GUID for Android or UUID for iOS. | ||
* | ||
* Usage - | ||
* Blueshift.resetDeviceId(); | ||
*/ | ||
function resetDeviceId():void; | ||
/** | ||
* Sync Blueshift Inbox messages on the local cache. | ||
* This will sync new messges, delete the expired messages, and update the unread status | ||
* of the message to the locally cached messges. | ||
* | ||
* Usage - | ||
* Blueshift.syncInboxMessages((status) => { | ||
* if (status) { | ||
* console.log("sync complete"); | ||
* } | ||
* }); | ||
*/ | ||
function syncInboxMessages(callback: function): void; | ||
/** | ||
* Get unread messages count to show on the notification badge. | ||
* | ||
* Usage - | ||
* Blueshift.getUnreadInboxMessageCount((count) => { | ||
* console.log("unread messages count"+count); | ||
* }); | ||
*/ | ||
function getUnreadInboxMessageCount(callback: function): void; | ||
/** | ||
* Get inbox messages list to show in the list view. | ||
* | ||
* Usage - | ||
* Blueshift.getInboxMessages((messages) => { | ||
* console.log("unread messages count"+count); | ||
* }); | ||
*/ | ||
function getInboxMessages(callback: function): void; | ||
/** | ||
* Show in-app notification for the Inbox message. | ||
* | ||
* @param {BlueshiftInboxMessage} message | ||
* | ||
* Usage - | ||
* Blueshift.showInboxMessage(); | ||
*/ | ||
function showInboxMessage(message: any): void; | ||
/** | ||
* Delete inbox message. | ||
* | ||
* @param {BlueshiftInboxMessage} message | ||
* | ||
* Usage - | ||
* Blueshift.deleteInboxMessage(); | ||
*/ | ||
function deleteInboxMessage(message: any, callback: function): void; | ||
/** | ||
* Process the Blueshift url and provide the final url to Linking's "url" callback | ||
@@ -428,2 +502,3 @@ * | ||
function isBlueshiftUrl(url : string): boolean; | ||
} |
1100
index.js
@@ -1,546 +0,654 @@ | ||
import { DeviceEventEmitter, Linking, NativeEventEmitter, NativeModules, Platform } from 'react-native'; | ||
import { | ||
DeviceEventEmitter, | ||
Linking, | ||
NativeEventEmitter, | ||
NativeModules, | ||
Platform, | ||
} from 'react-native'; | ||
const BlueshiftEventEmitter = new NativeEventEmitter(NativeModules.BlueshiftReactEventsManager); | ||
const BlueshiftEventEmitter = new NativeEventEmitter( | ||
NativeModules.BlueshiftReactEventsManager, | ||
); | ||
var Blueshift = { | ||
const Blueshift = { | ||
/** | ||
* Initialize the components of the Blueshift SDK. This mainly initializes the | ||
* event emitter instance to start firing the events when the app is ready to | ||
* receive them. | ||
* | ||
* Usage - | ||
* Blueshift.init(); | ||
* | ||
*/ | ||
init: function () { | ||
if (Platform.OS === 'android') { | ||
NativeModules.BlueshiftBridge.init(); | ||
} | ||
}, | ||
/** | ||
* Initialize the components of the Blueshift SDK. This mainly initializes the | ||
* event emitter instance to start firing the events when the app is ready to | ||
* receive them. | ||
* | ||
* Usage - | ||
* Blueshift.init(); | ||
* | ||
*/ | ||
init: function() { | ||
if (Platform.OS === 'android') { | ||
NativeModules.BlueshiftBridge.init(); | ||
} | ||
}, | ||
/** | ||
* 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 | ||
* | ||
*/ | ||
addEventListener: function (eventName, callback) { | ||
if (BlueshiftEventEmitter) { | ||
BlueshiftEventEmitter.addListener(eventName, callback); | ||
} | ||
/** | ||
* 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 | ||
* | ||
*/ | ||
addEventListener: function(eventName, callback) { | ||
if (BlueshiftEventEmitter) { | ||
BlueshiftEventEmitter.addListener(eventName, callback); | ||
} | ||
if (Platform.OS === 'android') { | ||
NativeModules.BlueshiftBridge.onAddEventListener(eventName); | ||
} | ||
}, | ||
if (Platform.OS === 'android') { | ||
NativeModules.BlueshiftBridge.onAddEventListener(eventName); | ||
} | ||
}, | ||
/** | ||
* Remove the event listener. | ||
* | ||
* Usage - | ||
* Blueshift.removeEventListener("PushNotificationClickedEvent"); | ||
* | ||
* @param {string} eventName Name of event remove the listener. | ||
* | ||
*/ | ||
removeEventListener: function (eventName) { | ||
if (BlueshiftEventEmitter) { | ||
BlueshiftEventEmitter.removeAllListeners(eventName); | ||
} | ||
}, | ||
/** | ||
* Remove the event listener. | ||
* | ||
* Usage - | ||
* Blueshift.removeEventListener("PushNotificationClickedEvent"); | ||
* | ||
* @param {string} eventName Name of event remove the listener. | ||
* | ||
*/ | ||
removeEventListener: function(eventName) { | ||
if (BlueshiftEventEmitter) { | ||
BlueshiftEventEmitter.removeAllListeners(eventName); | ||
} | ||
}, | ||
/** | ||
* Registers a page for showing in-app message. | ||
* | ||
* Usage - | ||
* Blueshift.registerForInAppMessage("IndexScreen"); | ||
* | ||
* @param {string} screenName Name of the screen. | ||
* | ||
*/ | ||
registerForInAppMessage: function (screenName) { | ||
NativeModules.BlueshiftBridge.registerForInAppMessage(screenName); | ||
}, | ||
/** | ||
* Registers a page for showing in-app message. | ||
* | ||
* Usage - | ||
* Blueshift.registerForInAppMessage("IndexScreen"); | ||
* | ||
* @param {string} screenName Name of the screen. | ||
* | ||
*/ | ||
registerForInAppMessage: function(screenName) { | ||
NativeModules.BlueshiftBridge.registerForInAppMessage(screenName); | ||
}, | ||
/** | ||
* Get registered screen name for in-app messages. | ||
* | ||
* Usage - | ||
* Blueshift.getRegisteredForInAppScreenName(screenName = { | ||
* console.log("registered screen name - " + screenName); | ||
* }); | ||
* | ||
*/ | ||
getRegisteredForInAppScreenName: function (callback) { | ||
NativeModules.BlueshiftBridge.getRegisteredForInAppScreenName(callback); | ||
}, | ||
/** | ||
* Unregisters a page from showing in-app message. | ||
* | ||
* Usage - | ||
* Blueshift.unregisterForInAppMessage(); | ||
* | ||
*/ | ||
unregisterForInAppMessage: function() { | ||
NativeModules.BlueshiftBridge.unregisterForInAppMessage(); | ||
}, | ||
/** | ||
* Unregisters a page from showing in-app message. | ||
* | ||
* Usage - | ||
* Blueshift.unregisterForInAppMessage(); | ||
* | ||
*/ | ||
unregisterForInAppMessage: function () { | ||
NativeModules.BlueshiftBridge.unregisterForInAppMessage(); | ||
}, | ||
/** | ||
* Fetches in-app messages from the Blueshift API and provides them in the callbacks. | ||
* | ||
* | ||
* Usage - | ||
* Blueshift.fetchInAppNotification(); | ||
* | ||
*/ | ||
/** | ||
* Fetches in-app messages from the Blueshift API and provides them in the callbacks. | ||
* | ||
* | ||
* Usage - | ||
* Blueshift.fetchInAppNotification(); | ||
* | ||
*/ | ||
fetchInAppNotification: function() { | ||
NativeModules.BlueshiftBridge.fetchInAppNotification(); | ||
}, | ||
fetchInAppNotification: function () { | ||
NativeModules.BlueshiftBridge.fetchInAppNotification(); | ||
}, | ||
/** | ||
* Display in-app message if the current page is registered for in-app messages. | ||
* | ||
* Usage - | ||
* Blueshift.displayInAppNotification(); | ||
* | ||
*/ | ||
/** | ||
* Display in-app message if the current page is registered for in-app messages. | ||
* | ||
* Usage - | ||
* Blueshift.displayInAppNotification(); | ||
* | ||
*/ | ||
displayInAppNotification: function() { | ||
NativeModules.BlueshiftBridge.displayInAppNotification(); | ||
}, | ||
displayInAppNotification: function () { | ||
NativeModules.BlueshiftBridge.displayInAppNotification(); | ||
}, | ||
/** | ||
* Sends an identify event with the details available. | ||
* | ||
* Usage - | ||
* Blueshift.Blueshift.identifyWithDetails({}) | ||
* | ||
* @param {object} details Additional params (if any) | ||
* | ||
*/ | ||
/** | ||
* Sends an identify event with the details available. | ||
* | ||
* Usage - | ||
* Blueshift.Blueshift.identifyWithDetails({}) | ||
* | ||
* @param {object} details Additional params (if any) | ||
* | ||
*/ | ||
identifyWithDetails: function(details) { | ||
NativeModules.BlueshiftBridge.identifyWithDetails(details); | ||
}, | ||
identifyWithDetails: function (details) { | ||
NativeModules.BlueshiftBridge.identifyWithDetails(details); | ||
}, | ||
/** | ||
* Send any custom event to Blueshift. | ||
* | ||
* 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. | ||
* | ||
*/ | ||
/** | ||
* Send any custom event to Blueshift. | ||
* | ||
* 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. | ||
* | ||
*/ | ||
trackCustomEvent: function(eventName, details, isBatch) { | ||
NativeModules.BlueshiftBridge.trackCustomEvent(eventName, details, isBatch); | ||
}, | ||
trackCustomEvent: function (eventName, details, isBatch) { | ||
NativeModules.BlueshiftBridge.trackCustomEvent(eventName, details, isBatch); | ||
}, | ||
/** | ||
* Track screen view using Blueshift. | ||
* | ||
* 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. | ||
* | ||
*/ | ||
trackScreenView: function(screenName, details, isBatch) { | ||
NativeModules.BlueshiftBridge.trackScreenView(screenName, details, isBatch); | ||
}, | ||
/** | ||
* Track screen view using Blueshift. | ||
* | ||
* 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. | ||
* | ||
*/ | ||
trackScreenView: function (screenName, details, isBatch) { | ||
NativeModules.BlueshiftBridge.trackScreenView(screenName, details, isBatch); | ||
}, | ||
/** | ||
* Save email in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoEmailId("test@test.com"); | ||
* | ||
* @param {string} emailId email of the customer. | ||
* | ||
*/ | ||
/** | ||
* Save email in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoEmailId("test@test.com"); | ||
* | ||
* @param {string} emailId email of the customer. | ||
* | ||
*/ | ||
setUserInfoEmailId: function (emailId) { | ||
NativeModules.BlueshiftBridge.setUserInfoEmailId(emailId); | ||
}, | ||
setUserInfoEmailId: function(emailId) { | ||
NativeModules.BlueshiftBridge.setUserInfoEmailId(emailId); | ||
}, | ||
/** | ||
* Save customerId in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoCustomerId("cust123456"); | ||
* | ||
* @param {string} customerId customerId of the customer. | ||
* | ||
*/ | ||
/** | ||
* Save customerId in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoCustomerId("cust123456"); | ||
* | ||
* @param {string} customerId customerId of the customer. | ||
* | ||
*/ | ||
setUserInfoCustomerId: function (customerId) { | ||
NativeModules.BlueshiftBridge.setUserInfoCustomerId(customerId); | ||
}, | ||
setUserInfoCustomerId: function(customerId) { | ||
NativeModules.BlueshiftBridge.setUserInfoCustomerId(customerId); | ||
}, | ||
/** | ||
* Save firstname in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoFirstName("John"); | ||
* | ||
* @param {string} firstname firstname of the customer. | ||
* | ||
*/ | ||
setUserInfoFirstName: function (firstname) { | ||
NativeModules.BlueshiftBridge.setUserInfoFirstName(firstname); | ||
}, | ||
/** | ||
* Save firstname in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoFirstName("John"); | ||
* | ||
* @param {string} firstname firstname of the customer. | ||
* | ||
*/ | ||
setUserInfoFirstName: function(firstname) { | ||
NativeModules.BlueshiftBridge.setUserInfoFirstName(firstname); | ||
}, | ||
/** | ||
* Save lastname in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoLastName("Cartor"); | ||
* | ||
* @param {string} lastname lastname of the customer. | ||
* | ||
*/ | ||
setUserInfoLastName: function (lastname) { | ||
NativeModules.BlueshiftBridge.setUserInfoLastName(lastname); | ||
}, | ||
/** | ||
* Save lastname in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoLastName("Cartor"); | ||
* | ||
* @param {string} lastname lastname of the customer. | ||
* | ||
*/ | ||
setUserInfoLastName: function(lastname) { | ||
NativeModules.BlueshiftBridge.setUserInfoLastName(lastname); | ||
}, | ||
/** | ||
* Save additional user info in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoExtras({"profession":"software engineer", "usertype":"premium"}); | ||
* | ||
* @param {object} extras additional user info. | ||
* | ||
*/ | ||
setUserInfoExtras: function (extras) { | ||
NativeModules.BlueshiftBridge.setUserInfoExtras(extras); | ||
}, | ||
/** | ||
* Save additional user info in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.setUserInfoExtras({"profession":"software engineer", "usertype":"premium"}); | ||
* | ||
* @param {object} extras additional user info. | ||
* | ||
*/ | ||
setUserInfoExtras: function(extras) { | ||
NativeModules.BlueshiftBridge.setUserInfoExtras(extras); | ||
}, | ||
/** | ||
* Remove all the saved user info from the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.removeUserInfo(); | ||
* | ||
*/ | ||
removeUserInfo: function () { | ||
NativeModules.BlueshiftBridge.removeUserInfo(); | ||
}, | ||
/** | ||
* Remove all the saved user info from the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.removeUserInfo(); | ||
* | ||
*/ | ||
removeUserInfo: function() { | ||
NativeModules.BlueshiftBridge.removeUserInfo(); | ||
}, | ||
/** | ||
* Enable/disable SDK's event tracking. | ||
* | ||
* Usage - | ||
* Blueshift.setEnableTracking(true); | ||
* | ||
* @param {boolean} enabled When true, tracking is enabled. When false, disabled. | ||
* | ||
*/ | ||
setEnableTracking: function (enabled) { | ||
NativeModules.BlueshiftBridge.setEnableTracking(enabled); | ||
}, | ||
/** | ||
* Enable/disable SDK's event tracking. | ||
* | ||
* Usage - | ||
* Blueshift.setEnableTracking(true); | ||
* | ||
* @param {boolean} enabled When true, tracking is enabled. When false, disabled. | ||
* | ||
*/ | ||
setEnableTracking: function(enabled) { | ||
NativeModules.BlueshiftBridge.setEnableTracking(enabled); | ||
}, | ||
/** | ||
* Opt-in or opt-out of push notifications sent from Blueshift. | ||
* | ||
* Usage - | ||
* Blueshift.setEnablePush(true); | ||
* | ||
* @param {boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
*/ | ||
setEnablePush: function (isEnabled) { | ||
NativeModules.BlueshiftBridge.setEnablePush(isEnabled); | ||
}, | ||
/** | ||
* Opt-in or opt-out of push notifications sent from Blueshift. | ||
* | ||
* Usage - | ||
* Blueshift.setEnablePush(true); | ||
* | ||
* @param {boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
*/ | ||
setEnablePush: function(isEnabled) { | ||
NativeModules.BlueshiftBridge.setEnablePush(isEnabled); | ||
}, | ||
/** | ||
* Opt-in or opt-out of in-app notifications sent from Blueshift. | ||
* | ||
* Usage - | ||
* Blueshift.setEnableInApp(true); | ||
* | ||
* @param {boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
*/ | ||
setEnableInApp: function (isEnabled) { | ||
NativeModules.BlueshiftBridge.setEnableInApp(isEnabled); | ||
}, | ||
/** | ||
* Opt-in or opt-out of in-app notifications sent from Blueshift. | ||
* | ||
* Usage - | ||
* Blueshift.setEnableInApp(true); | ||
* | ||
* @param {boolean} isEnabled When true, opt-in else opt-out. | ||
* | ||
*/ | ||
setEnableInApp: function(isEnabled) { | ||
NativeModules.BlueshiftBridge.setEnableInApp(isEnabled); | ||
}, | ||
/** | ||
* Set IDFA of the device in the Blueshift SDK. | ||
* Note - This is only applicable for the iOS devices. | ||
* | ||
* Usage - | ||
* Blueshift.setIDFA("EA7583CD-A667-48BC-B806-42ECB2B48606"); | ||
* | ||
* @param {string} IDFAString IDFA value. | ||
* | ||
*/ | ||
setIDFA: function (IDFAString) { | ||
if (Platform.OS === 'ios') { | ||
NativeModules.BlueshiftBridge.setIDFA(IDFAString); | ||
} | ||
}, | ||
/** | ||
* Set IDFA of the device in the Blueshift SDK. | ||
* Note - This is only applicable for the iOS devices. | ||
* | ||
* Usage - | ||
* Blueshift.setIDFA("EA7583CD-A667-48BC-B806-42ECB2B48606"); | ||
* | ||
* @param {string} IDFAString IDFA value. | ||
* | ||
*/ | ||
setIDFA: function(IDFAString) { | ||
if (Platform.OS === 'ios') { | ||
NativeModules.BlueshiftBridge.setIDFA(IDFAString); | ||
} | ||
}, | ||
/** | ||
* Register for remote notifications using SDK. Calling this method will show push permission dialogue to the user. | ||
* Note - This is only applicable for the iOS devices. | ||
* | ||
* Usage - | ||
* Blueshift.registerForRemoteNotification(); | ||
* | ||
*/ | ||
registerForRemoteNotification: function () { | ||
if (Platform.OS === 'ios') { | ||
NativeModules.BlueshiftBridge.registerForRemoteNotification(); | ||
} | ||
}, | ||
/** | ||
* Register for remote notifications using SDK. Calling this method will show push permission dialogue to the user. | ||
* Note - This is only applicable for the iOS devices. | ||
* | ||
* Usage - | ||
* Blueshift.registerForRemoteNotification(); | ||
* | ||
*/ | ||
registerForRemoteNotification: function() { | ||
if (Platform.OS === 'ios') { | ||
NativeModules.BlueshiftBridge.registerForRemoteNotification(); | ||
} | ||
}, | ||
/** | ||
* Set current location of the device in the Blueshift SDK. | ||
* Note - This is only applicable for the iOS devices. | ||
* | ||
* Usage - | ||
* Blueshift.setCurrentLocation(18.5245649,73.7228812); | ||
* | ||
* @param {Number} latitude location latitude value. | ||
* @param {Number} longitude location longitude value. | ||
* | ||
*/ | ||
setCurrentLocation: function (latitude, longitude) { | ||
if (Platform.OS === 'ios') { | ||
NativeModules.BlueshiftBridge.setCurrentLocation(latitude, longitude); | ||
} | ||
}, | ||
/** | ||
* Set current location of the device in the Blueshift SDK. | ||
* Note - This is only applicable for the iOS devices. | ||
* | ||
* Usage - | ||
* Blueshift.setCurrentLocation(18.5245649,73.7228812); | ||
* | ||
* @param {Number} latitude location latitude value. | ||
* @param {Number} longitude location longitude value. | ||
* | ||
*/ | ||
setCurrentLocation: function(latitude, longitude) { | ||
if (Platform.OS === 'ios') { | ||
NativeModules.BlueshiftBridge.setCurrentLocation(latitude, longitude) | ||
} | ||
}, | ||
/** | ||
* Calls Blueshift's live content API with email and given slot name and live content context. | ||
* | ||
* Usage - | ||
* Blueshift.getLiveContentByEmail("testSlot",{},(err,result) => { | ||
* if (result) { | ||
* console.log(result); | ||
* } else { | ||
* console.log(err); | ||
* } | ||
* }); | ||
* | ||
* @param {string} slot slot name of the live content. | ||
* @param {object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
*/ | ||
getLiveContentByEmail: function (slot, lcContext, callback) { | ||
NativeModules.BlueshiftBridge.getLiveContentByEmail( | ||
slot, | ||
lcContext, | ||
callback, | ||
); | ||
}, | ||
/** | ||
* Calls Blueshift's live content API with email and given slot name and live content context. | ||
* | ||
* Usage - | ||
* Blueshift.getLiveContentByEmail("testSlot",{},(err,result) => { | ||
* if (result) { | ||
* console.log(result); | ||
* } else { | ||
* console.log(err); | ||
* } | ||
* }); | ||
* | ||
* @param {string} slot slot name of the live content. | ||
* @param {object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
*/ | ||
getLiveContentByEmail: function(slot, lcContext, callback) { | ||
NativeModules.BlueshiftBridge.getLiveContentByEmail(slot,lcContext,callback); | ||
}, | ||
/** | ||
* Calls Blueshift's live content API with customer id and given slot name and live content context. | ||
* | ||
* Usage - | ||
* Blueshift.getLiveContentByCustomerId("testSlot",{},(err,result) => { | ||
* if (result) { | ||
* console.log(result); | ||
* } else { | ||
* console.log(err); | ||
* } | ||
* }); | ||
* | ||
* @param {string} slot slot name of the live content. | ||
* @param {object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
*/ | ||
getLiveContentByCustomerId: function (slot, lcContext, callback) { | ||
NativeModules.BlueshiftBridge.getLiveContentByCustomerId( | ||
slot, | ||
lcContext, | ||
callback, | ||
); | ||
}, | ||
/** | ||
* Calls Blueshift's live content API with customer id and given slot name and live content context. | ||
* | ||
* Usage - | ||
* Blueshift.getLiveContentByCustomerId("testSlot",{},(err,result) => { | ||
* if (result) { | ||
* console.log(result); | ||
* } else { | ||
* console.log(err); | ||
* } | ||
* }); | ||
* | ||
* @param {string} slot slot name of the live content. | ||
* @param {object} lcContext live content context. | ||
* @param {function} callback callback function. | ||
* | ||
*/ | ||
getLiveContentByCustomerId: function(slot, lcContext, callback) { | ||
NativeModules.BlueshiftBridge.getLiveContentByCustomerId(slot,lcContext,callback); | ||
}, | ||
/** | ||
* Calls Blueshift's live content API with device id and given slot name and live content context. | ||
* | ||
* Usage - | ||
* Blueshift.getLiveContentByDeviceId("testSlot",{},(err,result) => { | ||
* if (result) { | ||
* console.log(result); | ||
* } else { | ||
* console.log(err); | ||
* } | ||
* }); | ||
* | ||
* @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) { | ||
NativeModules.BlueshiftBridge.getLiveContentByDeviceId( | ||
slot, | ||
lcContext, | ||
callback, | ||
); | ||
}, | ||
/** | ||
* Calls Blueshift's live content API with device id and given slot name and live content context. | ||
* | ||
* Usage - | ||
* Blueshift.getLiveContentByDeviceId("testSlot",{},(err,result) => { | ||
* if (result) { | ||
* console.log(result); | ||
* } else { | ||
* console.log(err); | ||
* } | ||
* }); | ||
* | ||
* @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) { | ||
NativeModules.BlueshiftBridge.getLiveContentByDeviceId(slot,lcContext,callback); | ||
}, | ||
/** | ||
* Get opt-in or opt-out status of in-app notifications set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getEnableInAppStatus((value) => { | ||
* console.log("status"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getEnableInAppStatus: function (callback) { | ||
NativeModules.BlueshiftBridge.getEnableInAppStatus(callback); | ||
}, | ||
/** | ||
* Get opt-in or opt-out status of in-app notifications set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getEnableInAppStatus((value) => { | ||
* console.log("status"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getEnableInAppStatus: function(callback) { | ||
NativeModules.BlueshiftBridge.getEnableInAppStatus(callback); | ||
}, | ||
/** | ||
* Get opt-in or opt-out status of push notifications set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getEnablePushStatus((value) => { | ||
* console.log("status"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getEnablePushStatus: function (callback) { | ||
NativeModules.BlueshiftBridge.getEnablePushStatus(callback); | ||
}, | ||
/** | ||
* Get opt-in or opt-out status of push notifications set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getEnablePushStatus((value) => { | ||
* console.log("status"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getEnablePushStatus: function(callback) { | ||
NativeModules.BlueshiftBridge.getEnablePushStatus(callback); | ||
}, | ||
/** | ||
* Get status of event tracking set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getEnableTrackingStatus((value) => { | ||
* console.log("status"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getEnableTrackingStatus: function (callback) { | ||
NativeModules.BlueshiftBridge.getEnableTrackingStatus(callback); | ||
}, | ||
/** | ||
* Get status of event tracking set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getEnableTrackingStatus((value) => { | ||
* console.log("status"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getEnableTrackingStatus: function(callback) { | ||
NativeModules.BlueshiftBridge.getEnableTrackingStatus(callback); | ||
}, | ||
/** | ||
* Get email id string set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoEmailId((value) => { | ||
* console.log("Email id"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getUserInfoEmailId: function (callback) { | ||
NativeModules.BlueshiftBridge.getUserInfoEmailId(callback); | ||
}, | ||
/** | ||
* Get email id string set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoEmailId((value) => { | ||
* console.log("Email id"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getUserInfoEmailId: function(callback) { | ||
NativeModules.BlueshiftBridge.getUserInfoEmailId(callback); | ||
}, | ||
/** | ||
* Get customer id string set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoCustomerId((value) => { | ||
* console.log("Customer id"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getUserInfoCustomerId: function (callback) { | ||
NativeModules.BlueshiftBridge.getUserInfoCustomerId(callback); | ||
}, | ||
/** | ||
* Get customer id string set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoCustomerId((value) => { | ||
* console.log("Customer id"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getUserInfoCustomerId: function(callback) { | ||
NativeModules.BlueshiftBridge.getUserInfoCustomerId(callback); | ||
}, | ||
/** | ||
* Get first name string set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoFirstName((value) => { | ||
* console.log("First name"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getUserInfoFirstName: function (callback) { | ||
NativeModules.BlueshiftBridge.getUserInfoFirstName(callback); | ||
}, | ||
/** | ||
* Get first name string set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoFirstName((value) => { | ||
* console.log("First name"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getUserInfoFirstName: function(callback) { | ||
NativeModules.BlueshiftBridge.getUserInfoFirstName(callback); | ||
}, | ||
/** | ||
* Get last name string set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoLastName((value) => { | ||
* console.log("Last name"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getUserInfoLastName: function (callback) { | ||
NativeModules.BlueshiftBridge.getUserInfoLastName(callback); | ||
}, | ||
/** | ||
* Get last name string set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoLastName((value) => { | ||
* console.log("Last name"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getUserInfoLastName: function(callback) { | ||
NativeModules.BlueshiftBridge.getUserInfoLastName(callback); | ||
}, | ||
/** | ||
* Get extras JSON data set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoExtras((value) => { | ||
* console.log("Extras"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getUserInfoExtras: function (callback) { | ||
NativeModules.BlueshiftBridge.getUserInfoExtras(callback); | ||
}, | ||
/** | ||
* Get extras JSON data set in the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getUserInfoExtras((value) => { | ||
* console.log("Extras"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getUserInfoExtras: function(callback) { | ||
NativeModules.BlueshiftBridge.getUserInfoExtras(callback); | ||
}, | ||
/** | ||
* Get current device id string used by the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getCurrentDeviceId((value) => { | ||
* console.log("Device id"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getCurrentDeviceId: function (callback) { | ||
NativeModules.BlueshiftBridge.getCurrentDeviceId(callback); | ||
}, | ||
/** | ||
* Get current device id string used by the SDK. | ||
* | ||
* Usage - | ||
* Blueshift.getCurrentDeviceId((value) => { | ||
* console.log("Device id"+value); | ||
* }); | ||
* | ||
* @param {function} callback success callback. | ||
* | ||
*/ | ||
getCurrentDeviceId: function(callback) { | ||
NativeModules.BlueshiftBridge.getCurrentDeviceId(callback); | ||
}, | ||
/** | ||
* Reset the current device id. This is only applicable if the device id | ||
* source is set to GUID for Android or UUID for iOS. | ||
* | ||
* Usage - | ||
* Blueshift.resetDeviceId(); | ||
*/ | ||
resetDeviceId: function () { | ||
NativeModules.BlueshiftBridge.resetDeviceId(); | ||
}, | ||
/** | ||
* Process the Blueshift url and provide the final url to Linking's "url" callback | ||
* | ||
* @param {string} url | ||
* | ||
*/ | ||
processBlueshiftUrl: function(url) { | ||
if (Platform.OS === 'android') { | ||
NativeModules.BlueshiftBridge.processBlueshiftUrl(url); | ||
} | ||
}, | ||
/** | ||
* Sync Blueshift Inbox messages on the local cache. | ||
* This will sync new messges, delete the expired messages, and update the unread status | ||
* of the message to the locally cached messges. | ||
* | ||
* Usage - | ||
* Blueshift.syncInboxMessages((status) => { | ||
* if (status) { | ||
* console.log("sync complete"); | ||
* } | ||
* }); | ||
*/ | ||
syncInboxMessages: function (callback) { | ||
NativeModules.BlueshiftBridge.syncInboxMessages(callback); | ||
}, | ||
/** | ||
* Checks if the given Url is of Blueshift's format. | ||
* | ||
* @param {string} url | ||
*/ | ||
isBlueshiftUrl: function(url) { | ||
if (url) { | ||
let hasBlueshiftPath = url.includes("/track") || url.includes("/z/"); | ||
let hasBlueshiftArgs = url.includes("eid=") || (url.includes("mid=") && url.includes("uid=")); | ||
/** | ||
* Get unread messages count to show on the notification badge. | ||
* | ||
* Usage - | ||
* Blueshift.getUnreadInboxMessageCount((count) => { | ||
* console.log("unread messages count"+count); | ||
* }); | ||
*/ | ||
getUnreadInboxMessageCount: function (callback) { | ||
NativeModules.BlueshiftBridge.getUnreadInboxMessageCount(callback); | ||
}, | ||
return hasBlueshiftPath && hasBlueshiftArgs; | ||
} else { | ||
console.log("Blueshift: The URL is null.") | ||
} | ||
/** | ||
* Get inbox messages list to show in the list view. | ||
* | ||
* Usage - | ||
* Blueshift.getInboxMessages((messages) => { | ||
* console.log("unread messages count"+count); | ||
* }); | ||
*/ | ||
getInboxMessages: function (callback) { | ||
NativeModules.BlueshiftBridge.getInboxMessages(messages => { | ||
callback(messages); | ||
}); | ||
}, | ||
return false; | ||
}, | ||
} | ||
/** | ||
* Show in-app notification for the Inbox message. | ||
* | ||
* @param {BlueshiftInboxMessage} message | ||
* | ||
* Usage - | ||
* Blueshift.showInboxMessage(); | ||
*/ | ||
showInboxMessage: function (message) { | ||
NativeModules.BlueshiftBridge.showInboxMessage(message); | ||
}, | ||
/** | ||
* Delete inbox message. | ||
* | ||
* @param {BlueshiftInboxMessage} message | ||
* | ||
* Usage - | ||
* Blueshift.deleteInboxMessage(); | ||
*/ | ||
deleteInboxMessage: function (message, callback) { | ||
NativeModules.BlueshiftBridge.deleteInboxMessage(message, callback); | ||
}, | ||
module.exports = Blueshift; | ||
/** | ||
* Process the Blueshift url and provide the final url to Linking's "url" callback | ||
* | ||
* @param {string} url | ||
* | ||
*/ | ||
processBlueshiftUrl: function (url) { | ||
if (Platform.OS === 'android') { | ||
NativeModules.BlueshiftBridge.processBlueshiftUrl(url); | ||
} | ||
}, | ||
/** | ||
* Checks if the given Url is of Blueshift's format. | ||
* | ||
* @param {string} url | ||
*/ | ||
isBlueshiftUrl: function (url) { | ||
if (url) { | ||
let hasBlueshiftPath = url.includes('/track') || url.includes('/z/'); | ||
let hasBlueshiftArgs = | ||
url.includes('eid=') || (url.includes('mid=') && url.includes('uid=')); | ||
return hasBlueshiftPath && hasBlueshiftArgs; | ||
} else { | ||
console.log('Blueshift: The URL is null.'); | ||
} | ||
return false; | ||
}, | ||
}; | ||
module.exports = Blueshift; |
{ | ||
"name": "blueshift-react-native", | ||
"version": "1.0.3", | ||
"description": "React native plugin for Blueshift iOS and Android SDK.", | ||
"version": "1.1.0", | ||
"description": "Official React native plugin for Blueshift iOS and Android SDK.", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "types": "index.d.ts", |
# blueshift-react-native | ||
Ract native plugin for integrating Blueshift's iOS and Android SDKs to your React native application. | ||
Official React native plugin for integrating Blueshift's iOS and Android SDKs to your React native application. | ||
## Installation | ||
@@ -7,0 +6,0 @@ |
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 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
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
1443711
107
13936
42