smartech-appinbox-react-native
Version:
Smartech App Inbox SDK's React Native Plugin For React Native Projects.
105 lines (88 loc) • 3.7 kB
JavaScript
;
var _reactNative = require("react-native");
const LINKING_ERROR = `The package 'smartech-appinbox-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
ios: "- You have run 'pod install'\n",
default: ''
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
const SmartechAppinboxReactnativeModule = _reactNative.NativeModules.SmartechAppinboxReactNative ? _reactNative.NativeModules.SmartechAppinboxReactNative : new Proxy({}, {
get() {
throw new Error(LINKING_ERROR);
}
});
function defaultCallback(method, err, res) {
if (err) {
console.log('Smartech ' + method + ' default callback error', err);
} else {
console.log('Smartech ' + method + ' default callback result', res);
}
} // Used to handle callback
function callWithCallback(method, args, callback) {
if (typeof callback === 'undefined' || callback == null || typeof callback !== 'function') {
callback = (err, res) => {
defaultCallback(method, err, res);
};
}
if (args == null) {
args = [];
}
args.push(callback);
SmartechAppinboxReactnativeModule[method].apply(this, args);
}
var SmartechReact = {
/**
* This method is used to get the list of available categories
*/
getAppInboxCategoryList: function (callback) {
callWithCallback('getAppInboxCategoryList', null, callback);
},
/**
* This method is used to get the list of available messages based on selected categories
*/
getAppInboxMessagesWithCategory: function (appInboxCategoryArray, callback) {
callWithCallback('getAppInboxMessagesWithCategory', [appInboxCategoryArray], callback);
},
/**
* This method is used to get the list of available messages based on message type
*/
getAppInboxMessages: function (messageType, callback) {
callWithCallback('getAppInboxMessages', [messageType], callback);
},
/**
* This method is used to get the count of available messages based on message type
*/
getAppInboxMessageCount: function (messageType, callback) {
callWithCallback('getAppInboxMessageCount', [messageType], callback);
},
/**
* This method is used to Send this event once the AppInbox message is visible to the user by Smartech APPInbox SDK.
*/
markMessageAsViewed: function (appInboxMessage) {
SmartechAppinboxReactnativeModule.markMessageAsViewed(appInboxMessage);
},
/**
* Onclick of AppInbox message, you need to send this event to SDK. This method takes 2 parameters that are deeplink and payload of AppInbox message.
*/
markMessageAsClicked: function (trid, deeplink) {
SmartechAppinboxReactnativeModule.markMessageAsClicked(trid, deeplink);
},
/**
* This method is used to mimic the feature of swipe to delete the messages from your TableView by Smartech APPInbox SDK.
*/
markMessageAsDismissed: function (appInboxMessage, callback) {
callWithCallback('markMessageAsDismissed', [appInboxMessage], callback);
},
/**
* This method is used to get the All, latest and earilier messages by API call from your TableView by Smartech APPInbox SDK.
*/
getAppInboxMessagesByApiCall: function (messageLimit, messageType, appInboxCategoryArray, callback) {
callWithCallback('getAppInboxMessagesByApiCall', [messageLimit, messageType, appInboxCategoryArray], callback);
},
/**
* This method is used to mimic the feature of copyMessaged with click event.
*/
copyMessageAsClicked: function (selectedAction, trid) {
SmartechAppinboxReactnativeModule.copyMessageAsClicked(selectedAction, trid);
}
};
module.exports = SmartechReact;
//# sourceMappingURL=index.js.map