Skip to content

Commit

Permalink
Merge pull request #23 from apptentive/develop
Browse files Browse the repository at this point in the history
Release 5.1.0
  • Loading branch information
weeeBox authored May 14, 2018
2 parents e0d7944 + abe262a commit 4724d11
Show file tree
Hide file tree
Showing 16 changed files with 9,067 additions and 126 deletions.
37 changes: 37 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"extends": [
"airbnb",
"plugin:react/all",
"plugin:react-native/all"
],
"plugins": [
"react",
"react-native"
],
"ecmaFeatures": {
"jsx": true
},
"env": {
"es6": true,
"react-native/react-native": true
}, # Custom Disabled Rules
rules: {
camelcase: 0,
max-len: 0,
comma-dangle: ['error', {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "ignore",
"exports": "ignore",
"functions": "ignore",
}],
no-restricted-syntax: [
'error',
'ForOfStatement',
'LabeledStatement',
'WithStatement',
],
"security/detect-object-injection": 0,
"object-curly-newline": 0
}
}
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ This document lets you know what has changed in the React Native module. For cha
- [Android Changelog](https://github.com/apptentive/apptentive-android/blob/master/CHANGELOG.md)
- [iOS Changelog](https://github.com/apptentive/apptentive-ios/blob/master/CHANGELOG.md)

# 2018-05-14 - v5.1.0

- Apptentive Android SDK: 5.1.0
- Apptentive iOS SDK: 5.1.0

# 2018-03-30 - v5.0.0

- Apptentive Android SDK: 5.0.4
- Apptentive iOS SDK: 5.0.3
- Apptentive iOS SDK: 5.0.3
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ repositories {

dependencies {
compile 'com.facebook.react:react-native:+'
compile 'com.apptentive:apptentive-android:5.0.4'
compile 'com.apptentive:apptentive-android:5.1.1'
}

2 changes: 1 addition & 1 deletion android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="apptentive_distribution">React Native</string>
<string name="apptentive_distribution_version">5.0.0</string>
<string name="apptentive_distribution_version">5.1.0</string>
</resources>
2 changes: 1 addition & 1 deletion ios/RNApptentiveModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ - (dispatch_queue_t)methodQueue
if (configuration) {
configuration.appID = configurationDictionary[@"appleID"];
configuration.distributionName = @"React Native";
configuration.distributionVersion = @"5.0.0";
configuration.distributionVersion = @"5.1.0";
[Apptentive registerWithConfiguration:configuration];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(messageCenterUnreadCountChangedNotification:) name:ApptentiveMessageCenterUnreadCountChangedNotification object:nil];
Expand Down
96 changes: 48 additions & 48 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@

import { NativeModules } from 'react-native'
import { ApptentivePlatformSpecific } from './platform-specific'
import { NativeModules } from 'react-native';
import { ApptentivePlatformSpecific } from './platform-specific';

const { RNApptentiveModule } = NativeModules
const { RNApptentiveModule } = NativeModules;

export class ApptentiveConfiguration {
constructor(apptentiveKey, apptentiveSignature) {
this.apptentiveKey = apptentiveKey
this.apptentiveSignature = apptentiveSignature
this.logLevel = 'info'
this.shouldSanitizeLogMessages = true
this.apptentiveKey = apptentiveKey;
this.apptentiveSignature = apptentiveSignature;
this.logLevel = 'info';
this.shouldSanitizeLogMessages = true;
}
toString() {
return `(apptentiveKey=${this.apptentiveKey}, apptentiveSignature=${this.apptentiveSignature}, logLevel=${this.logLevel}, shouldSanitizeLogMessages=${shouldSanitizeLogMessages})`
return `(apptentiveKey=${this.apptentiveKey}, apptentiveSignature=${this.apptentiveSignature}, logLevel=${this.logLevel}, shouldSanitizeLogMessages=${this.shouldSanitizeLogMessages})`;
}
}

let _eventsRegistered = false
let _onUnreadMessageCountChanged = function(count) {}
let _onAuthenticationFailed = function(reason) {}
let _eventsRegistered = false;
let _onUnreadMessageCountChanged = function onUnreadMessageCountChanged(count) {};
let _onAuthenticationFailed = function onAuthenticationFailed(reason) {};

export class Apptentive {
/**
Expand All @@ -27,24 +27,24 @@ export class Apptentive {
*/
static register(apptentiveConfiguration) {
if (!_eventsRegistered) {
_eventsRegistered = true
_eventsRegistered = true;

// unread message count
const emitter = ApptentivePlatformSpecific.createApptentiveEventEmitter(RNApptentiveModule)
emitter.addListener('onUnreadMessageCountChanged', function(e: Event) {
const emitter = ApptentivePlatformSpecific.createApptentiveEventEmitter(RNApptentiveModule);
emitter.addListener('onUnreadMessageCountChanged', (e) => {
if (_onUnreadMessageCountChanged !== undefined) {
_onUnreadMessageCountChanged(e.count)
_onUnreadMessageCountChanged(e.count);
}
})
});

// auth failure callback
emitter.addListener('onAuthenticationFailed', function(e: Event) {
emitter.addListener('onAuthenticationFailed', (e) => {
if (_onAuthenticationFailed !== undefined) {
_onAuthenticationFailed(e.reason)
_onAuthenticationFailed(e.reason);
}
})
});
}
return RNApptentiveModule.register(apptentiveConfiguration)
return RNApptentiveModule.register(apptentiveConfiguration);
}

/**
Expand All @@ -53,7 +53,7 @@ export class Apptentive {
* @return Promise with success boolean or error.
*/
static presentMessageCenter(customData = null) {
return RNApptentiveModule.presentMessageCenter(customData)
return RNApptentiveModule.presentMessageCenter(customData);
}

// TODO: unread message count
Expand All @@ -63,15 +63,15 @@ export class Apptentive {
* @return Promise with boolean flag or error.
*/
static canShowMessageCenter() {
return RNApptentiveModule.canShowMessageCenter()
return RNApptentiveModule.canShowMessageCenter();
}

/**
* Checks whether the given event will cause an Interaction to be shown.
* @return Promise with boolean flag or error.
*/
static canShowInteraction(event) {
return RNApptentiveModule.canShowInteraction(event)
return RNApptentiveModule.canShowInteraction(event);
}

/**
Expand All @@ -81,7 +81,7 @@ export class Apptentive {
* @return Promise with boolean flag or error.
*/
static engage(event, customData = null) {
return RNApptentiveModule.engage(event, customData)
return RNApptentiveModule.engage(event, customData);
}

// TODO: extended data
Expand All @@ -90,7 +90,7 @@ export class Apptentive {
* @return Promise with person name or error.
*/
static getPersonName() {
return RNApptentiveModule.getPersonName()
return RNApptentiveModule.getPersonName();
}

/**
Expand All @@ -99,14 +99,14 @@ export class Apptentive {
* @return Promise with boolean flag or error.
*/
static setPersonName(value) {
return RNApptentiveModule.setPersonName(value)
return RNApptentiveModule.setPersonName(value);
}

/**
* @return Promise with person email or error.
*/
static getPersonEmail() {
return RNApptentiveModule.getPersonEmail()
return RNApptentiveModule.getPersonEmail();
}

/**
Expand All @@ -115,7 +115,7 @@ export class Apptentive {
* @return Promise with boolean flag or error.
*/
static setPersonEmail(value) {
return RNApptentiveModule.setPersonEmail(value)
return RNApptentiveModule.setPersonEmail(value);
}

/**
Expand All @@ -126,16 +126,16 @@ export class Apptentive {
*/
static addCustomPersonData(key, value) {
if (value !== null && value !== undefined) {
const type = typeof value
const type = typeof value;
if (type === 'string') {
return RNApptentiveModule.addCustomPersonDataString(key, value)
return RNApptentiveModule.addCustomPersonDataString(key, value);
} else if (type === 'number') {
return RNApptentiveModule.addCustomPersonDataNumber(key, value)
return RNApptentiveModule.addCustomPersonDataNumber(key, value);
} else if (type === 'boolean') {
return RNApptentiveModule.addCustomPersonDataBool(key, value)
return RNApptentiveModule.addCustomPersonDataBool(key, value);
}
}
return Promise.reject("Your value should be either a string, number or bool")
return Promise.reject(new Error('Your value should be either a string, number or bool'));
}

/**
Expand All @@ -144,7 +144,7 @@ export class Apptentive {
* @return Promise with boolean flag or error.
*/
static removeCustomPersonData(key) {
return RNApptentiveModule.removeCustomPersonData(key)
return RNApptentiveModule.removeCustomPersonData(key);
}

/**
Expand All @@ -155,16 +155,16 @@ export class Apptentive {
*/
static addCustomDeviceData(key, value) {
if (value !== null && value !== undefined) {
const type = typeof value
const type = typeof value;
if (type === 'string') {
return RNApptentiveModule.addCustomDeviceDataString(key, value)
return RNApptentiveModule.addCustomDeviceDataString(key, value);
} else if (type === 'number') {
return RNApptentiveModule.addCustomDeviceDataNumber(key, value)
return RNApptentiveModule.addCustomDeviceDataNumber(key, value);
} else if (type === 'boolean') {
return RNApptentiveModule.addCustomDeviceDataBool(key, value)
return RNApptentiveModule.addCustomDeviceDataBool(key, value);
}
}
return Promise.reject("Your value should be either a string, number or bool")
return Promise.reject(new Error('Your value should be either a string, number or bool'));
}

/**
Expand All @@ -173,7 +173,7 @@ export class Apptentive {
* @return Promise with boolean flag or error.
*/
static removeCustomDeviceData(key) {
return RNApptentiveModule.removeCustomDeviceData(key)
return RNApptentiveModule.removeCustomDeviceData(key);
}

/**
Expand All @@ -183,7 +183,7 @@ export class Apptentive {
* @return Promise with boolean flag or error.
*/
static logIn(token) {
return RNApptentiveModule.logIn(token)
return RNApptentiveModule.logIn(token);
}

/**
Expand All @@ -192,41 +192,41 @@ export class Apptentive {
* @return Promise with boolean flag or error.
*/
static logOut() {
return RNApptentiveModule.logOut()
return RNApptentiveModule.logOut();
}

/**
* @return Current callback for the unread message count change in the Message Center.
*/
static get onUnreadMessageCountChanged() {
return _onUnreadMessageCountChanged
return _onUnreadMessageCountChanged;
}

/**
* Sets current callback for the unread message count change in the Message Center.
* @param value Callback function with a single integer parameter.
*/
static set onUnreadMessageCountChanged(value) {
_onUnreadMessageCountChanged = value
_onUnreadMessageCountChanged = value;
}

/**
* @return Current callback for the authentication failures.
*/
static get onAuthenticationFailed() {
return _onAuthenticationFailed
return _onAuthenticationFailed;
}

/**
* Sets current callback for the authentication failures.
* @param value Callback function with a single string parameter.
*/
static set onAuthenticationFailed(value) {
_onAuthenticationFailed = value
_onAuthenticationFailed = value;
}
}

module.exports = {
Apptentive,
ApptentiveConfiguration
}
ApptentiveConfiguration,
};
8 changes: 4 additions & 4 deletions js/platform-specific.android.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DeviceEventEmitter } from 'react-native'
import { DeviceEventEmitter } from 'react-native';

export class ApptentivePlatformSpecific {
static createApptentiveEventEmitter(nativeModule) {
return DeviceEventEmitter
return DeviceEventEmitter;
}
}

module.exports = {
ApptentivePlatformSpecific
}
ApptentivePlatformSpecific,
};
8 changes: 4 additions & 4 deletions js/platform-specific.ios.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NativeEventEmitter } from 'react-native'
import { NativeEventEmitter } from 'react-native';

export class ApptentivePlatformSpecific {
static createApptentiveEventEmitter(nativeModule) {
return new NativeEventEmitter(nativeModule)
return new NativeEventEmitter(nativeModule);
}
}

module.exports = {
ApptentivePlatformSpecific
}
ApptentivePlatformSpecific,
};
Loading

0 comments on commit 4724d11

Please sign in to comment.