New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-appboy-sdk

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-appboy-sdk - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0

.eslintrc.json

11

CHANGELOG.md

@@ -0,1 +1,12 @@

## 1.0.0
- Targets [Appboy Android SDK version 1.15.3](https://github.com/Appboy/appboy-android-sdk/blob/master/CHANGELOG.md#1153) and [Appboy iOS SDK version 2.24.2](https://github.com/Appboy/appboy-ios-sdk/blob/master/CHANGELOG.md#2242).
- **Update Required** — Updates iOS push handling in the AppboyProject sample project to be compatible with iOS 10. For more information, refer to the CHANGELOG for [Appboy iOS SDK v2.24.0](https://github.com/Appboy/appboy-ios-sdk/blob/master/CHANGELOG.md#2240).
- Adds callbacks to the native bindings to provide function call results to React Native.
- Exposes `ReactAppboy.getCardCountForCategories()` and `ReactAppboy.getUnreadCardCountForCategories()` for retrieving News Feed card counts.
- Adds `ReactAppboy.getInitialURL()` for handling deep links when an iOS application is launched from the suspended state by clicking on a push notification with a deep link. See `componentDidMount()` in `AppboyProject.js` for a sample implementation.
- Exposes `ReactAppboy.setTwitterData()` and `ReactAppboy.setFacebookData()` for Twitter and Facebook integration.
- Removes `AppboyBroadcastReceiver.java` from the AppboyProject sample project, as Appboy Android SDK v1.15.0 removes the need for a custom `AppboyBroadcastReceiver` for Appboy push notifications.
- Updates the AppboyProject sample project to integrate session handling and in-app message manager registration using an [AppboyLifecycleCallbackListener](https://github.com/Appboy/appboy-android-sdk/blob/master/android-sdk-ui/src/com/appboy/AppboyLifecycleCallbackListener.java), as introduced in Appboy Android SDK v1.15.0.
- Updates the AppboyProject sample application to React Native v0.33.0.
## 0.3.0

@@ -2,0 +13,0 @@ - Renames Android module to conform to rnpm standard.

640

index.js
const AppboyReactBridge = require('react-native').NativeModules.AppboyReactBridge;
var ReactAppboy = {
/**
* When a user first uses Appboy on a device they are considered "anonymous". Use this method to identify a user
* with a unique ID, which enables the following:
*
* - If the same user is identified on another device, their user profile, usage history and event history will
* be shared across devices.
* - If your app is used on the same device by multiple people, you can assign each of them a unique identifier
* to track them separately. Only the most recent user on a particular browser will receive push
* notifications and in-app messages.
*
* When you request a user switch (which is any call to changeUser where the new user ID is not the same as the
* existing user ID), the current session for the previous user (anonymous or not) is automatically ended and
* a new session is started. Similarly, following a call to changeUser, any events which fire are guaranteed to
* be for the new user -- if an in-flight server request completes for the old user after the user switch no
* events will fire, so you do not need to worry about filtering out events from Appboy for old users.
*
* Additionally, if you identify a user which has never been identified on another device, the entire history of
* that user as an "anonymous" user on this device will be preserved and associated with the newly identified
* user. However, if you identify a user which *has* been identified in another app, any history which was
* already flushed to the server for the anonymous user on this device will become orphaned and will not be
* associated with any future users. These orphaned users are not considered in your user counts and will not
* be messaged.
*
* Note: Once you identify a user, you cannot revert to the "anonymous" user. The transition from anonymous to
* identified tracking is only allowed once because the initial anonymous user receives special treatment to
* allow for preservation of their history. As a result, we recommend against changing the user ID just because
* your app has entered a "logged out" state because it makes you unable to target the previously logged out user
* with re-engagement campaigns. If you anticipate multiple users on the same device, but only want to target one
* of them when your app is in a logged out state, we recommend separately keeping track of the user ID you want
* to target while logged out and switching back to that user ID as part of your app's logout process.
*
* @param {string} userId - A unique identifier for this user.
*/
changeUser: function (userId) {
AppboyReactBridge.changeUser(userId);
},
* This default callback logs errors and null or false results. AppboyReactBridge methods with callbacks will
* default to this if there is no user-provided callback.
* @callback appboyCallback
* @param {object} error - The callback error object
* @param {object} result - The method return value
*/
function appboyCallback(error, result) {
if (error) {
console.log(error);
} else if (result == null || result === false) {
console.log('Appboy API method returned null or false.');
}
}
/**
* Reports that the current user performed a custom named event.
* @param {string} eventName - The identifier for the event to track. Best practice is to track generic events
* useful for segmenting, instead of specific user actions (i.e. track watched_sports_video instead of
* watched_video_adrian_peterson_td_mnf). Value is limited to 255 characters in length, cannot begin with a $,
* and can only contain alphanumeric characters and punctuation.
* @param {object} [eventProperties] - Hash of properties for this event. Keys are limited to 255
* characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
* Values can be numeric, boolean, or strings 255 characters or shorter.
*/
* A helper method that wraps calls to AppboyReactBridge and passes in the
* default Appboy callback if no callback is provided.
* @param {function} methodName - The AppboyReactBridge function to call
* @param {array} argsArray - An array of arguments to pass into methodName
* @param {function(error, result)} callback - The user-provided callback
*/
function callFunctionWithCallback(methodName, argsArray, callback) {
// If user-provided callback is null, undefined, or not a function, use default Appboy callback
if (typeof callback === 'undefined' || callback == null || typeof callback !== 'function') {
callback = appboyCallback;
}
argsArray.push(callback);
methodName.apply(this, argsArray);
}
logCustomEvent: function (eventName, eventProperties) {
AppboyReactBridge.logCustomEvent(eventName, eventProperties);
},
var ReactAppboy = {
/**
* When launching an iOS application that has previously been force closed, React Native's Linking API doesn't
* support handling deep links embedded in push notifications. This is due to a race condition on startup between
* the native call to RCTLinkingManager and React's loading of its JavaScript. This function provides a workaround:
* If an application is launched from a push notification click, we return any Appboy deep links in the push payload.
* @param {function(string)} callback - A callback that retuns the deep link as a string. If there is no deep link, returns null.
*/
getInitialURL: function(callback) {
if (AppboyReactBridge.getInitialUrl) {
AppboyReactBridge.getInitialUrl((err, res) => {
if (err) {
console.log(err);
callback(null);
} else {
callback(res);
}
});
} else {
// AppboyReactBridge.getInitialUrl not implemented on Android
callback(null);
}
},
/**
* Reports that the current user made an in-app purchase. Useful for tracking and segmenting users.
* @param {string} productId - A string identifier for the product purchased, e.g. an SKU. Value is limited to
* 255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
* @param {float} price - The price paid. Base units depend on the currency. As an example, USD should be
* reported as Dollars.Cents, whereas JPY should be reported as a whole number of Yen. All provided
* values will be rounded to two digits with toFixed(2)
* @param {string} [currencyCode=USD] - Currencies should be represented as an ISO 4217 currency code. Supported
* currency symbols include: AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF,
* BMD, BND, BOB, BRL, BSD, BTC, BTN, BWP, BYR, BZD, CAD, CDF, CHF, CLF, CLP, CNY, COP, CRC, CUC, CUP, CVE,
* CZK, DJF, DKK, DOP, DZD, EEK, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GGP, GHS, GIP, GMD, GNF, GTQ, GYD,
* HKD, HNL, HRK, HTG, HUF, IDR, ILS, IMP, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW,
* KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRO, MTL,
* MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR,
* RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, STD, SVC, SYP, SZL, THB, TJS, TMT,
* TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VEF, VND, VUV, WST, XAF, XAG, XAU, XCD, XDR, XOF,
* XPD, XPF, XPT, YER, ZAR, ZMK, ZMW, and ZWL. Any other provided currency symbol will result in a logged
* warning and no other action taken by the SDK.
* @param {integer} [quantity=1] - The quantity of items purchased expressed as a whole number. Must be at least 1
* and at most 100.
* @param {object} [purchaseProperties] - Hash of properties for this purchase. Keys are limited to 255
* characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
* Values can be numeric, boolean, or strings 255 characters or shorter.
*/
logPurchase: function (productId, price, currencyCode, quantity, purchaseProperties) {
AppboyReactBridge.logPurchase(productId, price, currencyCode, quantity, purchaseProperties);
},
/**
* When a user first uses Appboy on a device they are considered "anonymous". Use this method to identify a user
* with a unique ID, which enables the following:
*
* - If the same user is identified on another device, their user profile, usage history and event history will
* be shared across devices.
* - If your app is used on the same device by multiple people, you can assign each of them a unique identifier
* to track them separately. Only the most recent user on a particular browser will receive push
* notifications and in-app messages.
*
* When you request a user switch (which is any call to changeUser where the new user ID is not the same as the
* existing user ID), the current session for the previous user (anonymous or not) is automatically ended and
* a new session is started. Similarly, following a call to changeUser, any events which fire are guaranteed to
* be for the new user -- if an in-flight server request completes for the old user after the user switch no
* events will fire, so you do not need to worry about filtering out events from Appboy for old users.
*
* Additionally, if you identify a user which has never been identified on another device, the entire history of
* that user as an "anonymous" user on this device will be preserved and associated with the newly identified
* user. However, if you identify a user which *has* been identified in another app, any history which was
* already flushed to the server for the anonymous user on this device will become orphaned and will not be
* associated with any future users. These orphaned users are not considered in your user counts and will not
* be messaged.
*
* Note: Once you identify a user, you cannot revert to the "anonymous" user. The transition from anonymous to
* identified tracking is only allowed once because the initial anonymous user receives special treatment to
* allow for preservation of their history. As a result, we recommend against changing the user ID just because
* your app has entered a "logged out" state because it makes you unable to target the previously logged out user
* with re-engagement campaigns. If you anticipate multiple users on the same device, but only want to target one
* of them when your app is in a logged out state, we recommend separately keeping track of the user ID you want
* to target while logged out and switching back to that user ID as part of your app's logout process.
*
* @param {string} userId - A unique identifier for this user.
*/
changeUser: function(userId) {
AppboyReactBridge.changeUser(userId);
},
/**
* Submits feedback to Appboy.
* @param {string} email - The email of the user submitting feedback.
* @param {string} feedback - The content of the user feedback.
* @param {boolean} isBug - If the feedback is reporting a bug or not.
*/
submitFeedback: function (email, feedback, isBug) {
AppboyReactBridge.submitFeedback(email, feedback, isBug);
},
/**
* Reports that the current user performed a custom named event.
* @param {string} eventName - The identifier for the event to track. Best practice is to track generic events
* useful for segmenting, instead of specific user actions (i.e. track watched_sports_video instead of
* watched_video_adrian_peterson_td_mnf). Value is limited to 255 characters in length, cannot begin with a $,
* and can only contain alphanumeric characters and punctuation.
* @param {object} [eventProperties] - Hash of properties for this event. Keys are limited to 255
* characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
* Values can be numeric, boolean, or strings 255 characters or shorter.
*/
logCustomEvent: function(eventName, eventProperties) {
AppboyReactBridge.logCustomEvent(eventName, eventProperties);
},
// Appboy user methods
/**
* Sets a custom user attribute. This can be any key/value pair and is used to collect extra information about the
* user.
* @param {string} key - The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
* a $, and can only contain alphanumeric characters and punctuation.
* @param value - Can be numeric, boolean, a Date object, a string, or an array of strings. Strings are limited to
* 255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
* Passing a null value will remove this custom attribute from the user.
*/
setCustomUserAttribute: function (key, value) {
var valueType = typeof(value);
if (value instanceof Date) {
AppboyReactBridge.setDateCustomUserAttribute(key, Math.floor(value.getTime() / 1000));
/**
* Reports that the current user made an in-app purchase. Useful for tracking and segmenting users.
* @param {string} productId - A string identifier for the product purchased, e.g. an SKU. Value is limited to
* 255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
* @param {float} price - The price paid. Base units depend on the currency. As an example, USD should be
* reported as Dollars.Cents, whereas JPY should be reported as a whole number of Yen. All provided
* values will be rounded to two digits with toFixed(2)
* @param {string} [currencyCode=USD] - Currencies should be represented as an ISO 4217 currency code. Supported
* currency symbols include: AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF,
* BMD, BND, BOB, BRL, BSD, BTC, BTN, BWP, BYR, BZD, CAD, CDF, CHF, CLF, CLP, CNY, COP, CRC, CUC, CUP, CVE,
* CZK, DJF, DKK, DOP, DZD, EEK, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GGP, GHS, GIP, GMD, GNF, GTQ, GYD,
* HKD, HNL, HRK, HTG, HUF, IDR, ILS, IMP, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW,
* KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRO, MTL,
* MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR,
* RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, STD, SVC, SYP, SZL, THB, TJS, TMT,
* TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VEF, VND, VUV, WST, XAF, XAG, XAU, XCD, XDR, XOF,
* XPD, XPF, XPT, YER, ZAR, ZMK, ZMW, and ZWL. Any other provided currency symbol will result in a logged
* warning and no other action taken by the SDK.
* @param {integer} [quantity=1] - The quantity of items purchased expressed as a whole number. Must be at least 1
* and at most 100.
* @param {object} [purchaseProperties] - Hash of properties for this purchase. Keys are limited to 255
* characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
* Values can be numeric, boolean, or strings 255 characters or shorter.
*/
logPurchase: function(productId, price, currencyCode, quantity, purchaseProperties) {
AppboyReactBridge.logPurchase(productId, price, currencyCode, quantity, purchaseProperties);
},
/**
* Submits feedback to Appboy.
* @param {string} email - The email of the user submitting feedback.
* @param {string} feedback - The content of the user feedback.
* @param {boolean} isBug - If the feedback is reporting a bug or not.
* @param {function(error, result)} callback - A callback that receives the function call result.
*/
submitFeedback: function(email, feedback, isBug, callback) {
callFunctionWithCallback(AppboyReactBridge.submitFeedback, [email, feedback, isBug], callback);
},
// Appboy user methods
/**
* Sets a custom user attribute. This can be any key/value pair and is used to collect extra information about the
* user.
* @param {string} key - The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
* a $, and can only contain alphanumeric characters and punctuation.
* @param value - Can be numeric, boolean, a Date object, a string, or an array of strings. Strings are limited to
* 255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
* Passing a null value will remove this custom attribute from the user.
* @param {function(error, result)} callback - A callback that receives the function call result.
*/
setCustomUserAttribute: function(key, value, callback) {
var valueType = typeof (value);
if (value instanceof Date) {
callFunctionWithCallback(AppboyReactBridge.setDateCustomUserAttribute, [key, Math.floor(value.getTime() / 1000)], callback);
} else if (value instanceof Array) {
AppboyReactBridge.setCustomUserAttributeArray(key, value);
} else if (valueType === "boolean") {
AppboyReactBridge.setBoolCustomUserAttribute(key, value);
} else if (valueType === "string") {
AppboyReactBridge.setStringCustomUserAttribute(key, value);
} else if (valueType === "number") {
callFunctionWithCallback(AppboyReactBridge.setCustomUserAttributeArray, [key, value], callback);
} else if (valueType === 'boolean') {
callFunctionWithCallback(AppboyReactBridge.setBoolCustomUserAttribute, [key, value], callback);
} else if (valueType === 'string') {
callFunctionWithCallback(AppboyReactBridge.setStringCustomUserAttribute, [key, value], callback);
} else if (valueType === 'number') {
if (parseInt(value) === parseFloat(value)) {
AppboyReactBridge.setIntCustomUserAttribute(key, value);
callFunctionWithCallback(AppboyReactBridge.setIntCustomUserAttribute, [key, value], callback);
} else {
AppboyReactBridge.setDoubleCustomUserAttribute(key, value);
callFunctionWithCallback(AppboyReactBridge.setDoubleCustomUserAttribute, [key, value], callback);
}
}
},
},
/**
* Increment/decrement the value of a custom attribute. Only numeric custom attributes can be incremented. Attempts to
* increment a custom attribute that is not numeric be ignored. If you increment a custom attribute that has not
* previously been set, a custom attribute will be created and assigned the value of incrementValue. To decrement
* the value of a custom attribute, use a negative incrementValue.
* @param {string} key - The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
* a $, and can only contain alphanumeric characters and punctuation.
* @param {integer} - May be negative to decrement.
*/
incrementCustomUserAttribute: function (key, value) {
AppboyReactBridge.incrementCustomUserAttribute(key, value);
},
/**
* Increment/decrement the value of a custom attribute. Only numeric custom attributes can be incremented. Attempts to
* increment a custom attribute that is not numeric be ignored. If you increment a custom attribute that has not
* previously been set, a custom attribute will be created and assigned the value of incrementValue. To decrement
* the value of a custom attribute, use a negative incrementValue.
* @param {string} key - The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
* a $, and can only contain alphanumeric characters and punctuation.
* @param {integer} value - May be negative to decrement.
* @param {function(error, result)} callback - A callback that receives the function call result.
*/
incrementCustomUserAttribute: function(key, value, callback) {
callFunctionWithCallback(AppboyReactBridge.incrementCustomUserAttribute, [key, value], callback);
},
/**
* Sets the first name of the user.
* @param {string} firstName - Limited to 255 characters in length.
*/
setFirstName: function (firstName) {
AppboyReactBridge.setFirstName(firstName);
},
/**
* Sets the first name of the user.
* @param {string} firstName - Limited to 255 characters in length.
*/
setFirstName: function(firstName) {
AppboyReactBridge.setFirstName(firstName);
},
/**
* Sets the last name of the user.
* @param {string} lastName - Limited to 255 characters in length.
*/
setLastName: function (lastName) {
AppboyReactBridge.setLastName(lastName);
},
/**
* Sets the last name of the user.
* @param {string} lastName - Limited to 255 characters in length.
*/
setLastName: function(lastName) {
AppboyReactBridge.setLastName(lastName);
},
/**
* Sets the email address of the user.
* @param {string} email - Must pass RFC-5322 email address validation.
*/
setEmail: function (email) {
AppboyReactBridge.setEmail(email);
},
/**
* Sets the email address of the user.
* @param {string} email - Must pass RFC-5322 email address validation.
*/
setEmail: function(email) {
AppboyReactBridge.setEmail(email);
},
/**
* Sets the gender of the user.
* @param {ab.User.Genders} gender - Generally 'm' or 'f'.
*/
setGender: function (gender) {
AppboyReactBridge.setGender(gender);
},
/**
* Sets the gender of the user.
* @param {Genders} gender - Limited to m or f
* @param {function(error, result)} callback - A callback that receives the function call result.
*/
setGender: function(gender, callback) {
callFunctionWithCallback(AppboyReactBridge.setGender, [gender], callback);
},
/**
* Sets the country for the user.
* @param {string} country - Limited to 255 characters in length.
*/
setCountry: function (country) {
AppboyReactBridge.setCountry(country);
},
/**
* Sets the country for the user.
* @param {string} country - Limited to 255 characters in length.
*/
setCountry: function(country) {
AppboyReactBridge.setCountry(country);
},
/**
* Sets the home city for the user.
* @param {string} homeCity - Limited to 255 characters in length.
*/
setHomeCity: function (homeCity) {
AppboyReactBridge.setHomeCity(homeCity);
},
/**
* Sets the home city for the user.
* @param {string} homeCity - Limited to 255 characters in length.
*/
setHomeCity: function(homeCity) {
AppboyReactBridge.setHomeCity(homeCity);
},
/**
* Sets the phone number of the user.
* @param {string} phoneNumber - A phone number is considered valid if it is no more than 255 characters in length and
* contains only numbers, whitespace, and the following special characters +.-()
*/
setPhoneNumber: function (phoneNumber) {
AppboyReactBridge.setPhoneNumber(phoneNumber);
},
/**
* Sets the phone number of the user.
* @param {string} phoneNumber - A phone number is considered valid if it is no more than 255 characters in length and
* contains only numbers, whitespace, and the following special characters +.-()
*/
setPhoneNumber: function(phoneNumber) {
AppboyReactBridge.setPhoneNumber(phoneNumber);
},
/**
* Sets the url for the avatar image for the user, which will be displayed on the user profile and throughout the Appboy
* dashboard.
* @param {string} avatarImageUrl
*/
setAvatarImageUrl: function (avatarImageUrl) {
AppboyReactBridge.setAvatarImageUrl(avatarImageUrl);
},
/**
* Sets the url for the avatar image for the user, which will be displayed on the user profile and throughout the Appboy
* dashboard.
* @param {string} avatarImageUrl
*/
setAvatarImageUrl: function(avatarImageUrl) {
AppboyReactBridge.setAvatarImageUrl(avatarImageUrl);
},
/**
* Sets the date of birth of the user.
* @param {integer} year
* @param {integer} month - 1-12
* @param {integer} day
*/
setDateOfBirth: function (year, month, day) {
AppboyReactBridge.setDateOfBirth(year, month, day);
},
/**
* Sets the date of birth of the user.
* @param {integer} year
* @param {integer} month - 1-12
* @param {integer} day
*/
setDateOfBirth: function(year, month, day) {
AppboyReactBridge.setDateOfBirth(year, month, day);
},
/**
* Sets whether the user should be sent push campaigns.
* @param {NotificationSubscriptionTypes} notificationSubscriptionType - Notification setting (explicitly
* opted-in, subscribed, or unsubscribed).
*/
setPushNotificationSubscriptionType: function (notificationSubscriptionType) {
AppboyReactBridge.setPushNotificationSubscriptionType(notificationSubscriptionType);
},
/**
* Sets whether the user should be sent push campaigns.
* @param {NotificationSubscriptionTypes} notificationSubscriptionType - Notification setting (explicitly
* opted-in, subscribed, or unsubscribed).
* @param {function(error, result)} callback - A callback that receives the function call result.
*/
setPushNotificationSubscriptionType: function(notificationSubscriptionType, callback) {
callFunctionWithCallback(AppboyReactBridge.setPushNotificationSubscriptionType, [notificationSubscriptionType], callback);
},
/**
* Sets whether the user should be sent email campaigns.
* @param {NotificationSubscriptionTypes} notificationSubscriptionType - Notification setting (explicitly
* opted-in, subscribed, or unsubscribed).
*/
setEmailNotificationSubscriptionType: function (notificationSubscriptionType) {
AppboyReactBridge.setEmailNotificationSubscriptionType(notificationSubscriptionType);
},
/**
* Sets whether the user should be sent email campaigns.
* @param {NotificationSubscriptionTypes} notificationSubscriptionType - Notification setting (explicitly
* opted-in, subscribed, or unsubscribed).
* @param {function(error, result)} callback - A callback that receives the function call result.
*/
setEmailNotificationSubscriptionType: function(notificationSubscriptionType, callback) {
callFunctionWithCallback(AppboyReactBridge.setEmailNotificationSubscriptionType, [notificationSubscriptionType], callback);
},
/**
* Adds a string to a custom atttribute string array, or creates that array if one doesn't exist.
* @param {string} key - The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
* a $, and can only contain alphanumeric characters and punctuation.
* @param {string} value - The string to be added to the array. Strings are limited to 255 characters in length, cannot
* begin with a $, and can only contain alphanumeric characters and punctuation.
*/
addToCustomUserAttributeArray: function (key, value) {
AppboyReactBridge.addToCustomAttributeArray(key, value);
},
/**
* Adds a string to a custom atttribute string array, or creates that array if one doesn't exist.
* @param {string} key - The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
* a $, and can only contain alphanumeric characters and punctuation.
* @param {string} value - The string to be added to the array. Strings are limited to 255 characters in length, cannot
* begin with a $, and can only contain alphanumeric characters and punctuation.
* @param {function(error, result)} callback - A callback that receives the function call result.
*/
addToCustomUserAttributeArray: function(key, value, callback) {
callFunctionWithCallback(AppboyReactBridge.addToCustomAttributeArray, [key, value], callback);
},
/**
* Removes a string from a custom attribute string array.
* @param {string} key - The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
* a $, and can only contain alphanumeric characters and punctuation.
* @param {string} value - The string to be removed from the array. Strings are limited to 255 characters in length,
* cannot beging with a $, and can only contain alphanumeric characters and punctuation.
*/
removeFromCustomUserAttributeArray: function (key, value) {
AppboyReactBridge.removeFromCustomAttributeArray(key, value);
},
/**
* Removes a string from a custom attribute string array.
* @param {string} key - The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
* a $, and can only contain alphanumeric characters and punctuation.
* @param {string} value - The string to be removed from the array. Strings are limited to 255 characters in length,
* cannot beging with a $, and can only contain alphanumeric characters and punctuation.
* @param {function(error, result)} callback - A callback that receives the function call result.
*/
removeFromCustomUserAttributeArray: function(key, value, callback) {
callFunctionWithCallback(AppboyReactBridge.removeFromCustomAttributeArray, [key, value], callback);
},
/**
* Unsets a custom user attribute.
* @param {string} key - The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
* a $, and can only contain alphanumeric characters and punctuation.
*/
unsetCustomUserAttribute: function (key) {
AppboyReactBridge.unsetCustomUserAttribute(key);
},
/**
* Unsets a custom user attribute.
* @param {string} key - The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
* a $, and can only contain alphanumeric characters and punctuation.
* @param {function(error, result)} callback - A callback that receives the function call result.
*/
unsetCustomUserAttribute: function(key, callback) {
callFunctionWithCallback(AppboyReactBridge.unsetCustomUserAttribute, [key], callback);
},
// Other
/**
* Launches the News Feed UI element.
*/
launchNewsFeed: function () {
AppboyReactBridge.launchNewsFeed();
},
/**
* Sets user Twitter data.
*
* @param {integer} id - The Twitter user Id. May not be null.
* @param {string} screenName - The user's Twitter handle
* @param {string} name - The user's name
* @param {string} description - A description of the user
* @param {integer} followersCount - Number of Twitter users following this user. May not be null.
* @param {integer} friendsCount - Number of Twitter users this user is following. May not be null.
* @param {integer} statusesCount - Number of Tweets by this user. May not be null.
* @param {string} profileImageUrl - Link to profile image
*/
setTwitterData: function(id, screenName, name, description, followersCount, friendsCount, statusesCount, profileImageUrl) {
if (id !== null && followersCount !== null && friendsCount !== null && statusesCount !== null) {
AppboyReactBridge.setTwitterData(id, screenName, name, description, followersCount, friendsCount, statusesCount, profileImageUrl);
} else {
console.log('Invalid null argument(s) passed to ReactAppboy.setTwitterData(). Twitter data not set.');
}
},
/**
* Launches the Feedback UI element. Not currently supported on Android.
*/
launchFeedback: function () {
AppboyReactBridge.launchFeedback();
},
/**
* Sets user Facebook data.
*
* @param {object} facebookUserDictionary - The dictionary returned from facebook with facebook graph api endpoint "/me". Please
* refer to https://developers.facebook.com/docs/graph-api/reference/v2.7/user for more information.
* Note: Android only supports the firstName, lastName, email, bio, cityName, gender, and birthday fields. All other user fields will be dropped.
* @param {integer} numberOfFriends - The length of the friends array from facebook. You can get the array from the dictionary returned
* from facebook with facebook graph api endpoint "/me/friends", under the key "data". Please refer to
* https://developers.facebook.com/docs/graph-api/reference/v2.7/user/friends for more information. May not be null.
* @param {Array} likes - The array of user's facebook likes from facebook. You can get the array from the dictionary returned
* from facebook with facebook graph api endpoint "/me/likes", under the key "data"; Please refer to
* https://developers.facebook.com/docs/graph-api/reference/v2.7/user/likes for more information.
*/
setFacebookData: function(facebookUserDictionary, numberOfFriends, likes) {
if (numberOfFriends !== null) {
AppboyReactBridge.setFacebookData(facebookUserDictionary, numberOfFriends, likes);
} else {
console.log('Invalid null argument(s) passed to ReactAppboy.setFacebookData(). Facebook data not set.');
}
},
NotificationSubscriptionTypes: {
"OPTED_IN": 'opted_in',
"SUBSCRIBED": 'subscribed',
"UNSUBSCRIBED": 'unsubscribed'
},
// News Feed
/**
* Launches the News Feed UI element.
*/
launchNewsFeed: function() {
AppboyReactBridge.launchNewsFeed();
},
Genders: {
"MALE": 'm',
"FEMALE": 'f'
/**
* Returns the current number of News Feed cards for the given category.
* @param {CardCategory} category - Card category. Use ReactAppboy.CardCategory.ALL to get the total card count.
* @param {function(error, result)} callback - A callback that receives the function call result.
* Note that for Android, a successful result relies on a FeedUpdatedEvent being posted at least once. There is also a slight
* race condition around calling changeUser, which requests a feed refresh, so the counts may not always be accurate.
*/
getCardCountForCategories: function(category, callback) {
callFunctionWithCallback(AppboyReactBridge.getCardCountForCategories, [category], callback);
},
/**
* Returns the number of unread News Feed cards for the given category.
* @param {CardCategory} category - Card category. Use ReactAppboy.CardCategory.ALL to get the total unread card count.
* @param {function(error, result)} callback - A callback that receives the function call result.
* Note that for Android, a successful result relies on a FeedUpdatedEvent being posted at least once. There is also a slight
* race condition around calling changeUser, which requests a feed refresh, so the counts may not always be accurate.
*/
getUnreadCardCountForCategories: function(category, callback) {
callFunctionWithCallback(AppboyReactBridge.getUnreadCardCountForCategories, [category], callback);
},
// Feedback
/**
* Launches the Feedback UI element. Not currently supported on Android.
*/
launchFeedback: function() {
AppboyReactBridge.launchFeedback();
},
// Enums
CardCategory: {
'ADVERTISING': 'advertising',
'ANNOUNCEMENTS': 'announcements',
'NEWS': 'news',
'SOCIAL': 'social',
'NO_CATEGORY': 'no_category',
'ALL': 'all'
},
NotificationSubscriptionTypes: {
'OPTED_IN': 'opted_in',
'SUBSCRIBED': 'subscribed',
'UNSUBSCRIBED': 'unsubscribed'
},
Genders: {
'MALE': 'm',
'FEMALE': 'f'
}
}
};
module.exports = ReactAppboy;
Copyright (c) 2016 Appboy, Inc.
All rights reserved.
* Use of source code or binaries contained within Appboy's SDKS are permitted only to enable use of the Appboy platform by customers of Appboy.
* Modification of source code and inclusion in mobile apps is explicitly allowed provided that all other conditions are met.
* Neither the name of Appboy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
* Redistribution of source code or binaries is disallowed except with specific prior written permission. Any such redistribution must retain the above copyright notice, this list of conditions and the following disclaimer.
* The use of source code or binaries contained within Appboy's sample apps, documentation, stub APIs and other related utilities is permitted only to enable testing and quality assurance of integrations with the Appboy platform by current customers of Appboy.
* The use of source code or binaries contained within Appboy's SDKs is permitted only to enable use of the Appboy platform by current customers of Appboy.
* Modification of source code contained within this repository or inclusion of such source in any non-Appboy app, website, or related code is only permitted provided that all other conditions set forth herein are met.
* Neither the name "Appboy" nor the names of any of its contributors may be used to endorse or promote products derived from this software without the express prior written permission of Appboy.
* Redistribution of source code or binaries is strictly prohibited except with the express prior written permission of Appboy. Any such redistribution must retain the above copyright notice, this list of conditions and the following disclaimer:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE USER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{
"name": "react-native-appboy-sdk",
"version": "0.3.0",
"version": "1.0.0",
"description": "Appboy SDK for React Native.",

@@ -30,3 +30,17 @@ "main": "index.js",

},
"homepage": "https://github.com/Appboy/appboy-react-sdk#readme"
"homepage": "https://github.com/Appboy/appboy-react-sdk#readme",
"devDependencies": {
"eslint": "^3.4.0",
"eslint-config-standard": "^6.0.0",
"eslint-config-standard-jsx": "^3.0.0",
"eslint-config-standard-react": "^4.0.0",
"eslint-plugin-promise": "^2.0.1",
"eslint-plugin-react": "^6.2.0",
"eslint-plugin-standard": "^2.0.0",
"i": "^0.3.5"
},
"scripts": {
"lint": "./node_modules/.bin/eslint index.js */**.js",
"lint-fix": "./node_modules/.bin/eslint --fix index.js */**.js"
}
}

@@ -39,3 +39,15 @@ ![Appboy Logo](https://github.com/Appboy/appboy-react-sdk/blob/master/Appboy_Logo_400x100.png)

2. `rnpm link`
3. Add the Appboy repository to your project:
```gradle
// file: android/build.gradle
...
allprojects {
repositories {
...
maven { url "http://appboy.github.io/appboy-android-sdk/sdk" }
}
}
```
#### Android without rnpm

@@ -42,0 +54,0 @@ 1. `npm install react-native-appboy-sdk@latest --save`

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc