Skip to content

Commit

Permalink
Fix Tabbing
Browse files Browse the repository at this point in the history
• Minor commit to fix tabbing. At some point the tabbing in index.js was completely messed up.
  • Loading branch information
Nightsd01 committed Oct 24, 2018
1 parent 752ea09 commit 801d158
Showing 1 changed file with 59 additions and 59 deletions.
118 changes: 59 additions & 59 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,39 @@ var _notificationCache = new Map();
var _listeners = [];

if (RNOneSignal != null) {
oneSignalEventEmitter = new NativeEventEmitter(RNOneSignal);
oneSignalEventEmitter = new NativeEventEmitter(RNOneSignal);

for(var i = 0; i < eventBroadcastNames.length; i++) {
var eventBroadcastName = eventBroadcastNames[i];
var eventName = _eventNames[i];
for(var i = 0; i < eventBroadcastNames.length; i++) {
var eventBroadcastName = eventBroadcastNames[i];
var eventName = _eventNames[i];

_listeners[eventName] = handleEventBroadcast(eventName, eventBroadcastName)
}
_listeners[eventName] = handleEventBroadcast(eventName, eventBroadcastName)
}
}

function handleEventBroadcast(type, broadcast) {
return oneSignalEventEmitter.addListener(
broadcast, (notification) => {
return oneSignalEventEmitter.addListener(
broadcast, (notification) => {
// Check if we have added listener for this type yet
// Cache the result first if we have not.
var handler = _notificationHandler.get(type);

if (handler) {
handler(notification);
handler(notification);
} else {
_notificationCache.set(type, notification);
_notificationCache.set(type, notification);
}
}
);
}
);
}

function checkIfInitialized() {
return RNOneSignal != null;
return RNOneSignal != null;
}

export default class OneSignal {
static addEventListener(type: any, handler: Function) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

// Listen to events of notification received, opened, device registered and IDSAvailable.

Expand All @@ -74,7 +74,7 @@ export default class OneSignal {
}

static removeEventListener(type, handler) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

invariant(
type === 'received' || type === 'opened' || type === 'ids' || type == 'emailSubscription',
Expand All @@ -85,15 +85,15 @@ export default class OneSignal {
}

static clearListeners() {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

for(var i = 0; i < _eventNames.length; i++) {
_listeners[_eventNames].remove();
}
}

static registerForPushNotifications() {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (Platform.OS === 'ios') {
RNOneSignal.registerForPushNotifications();
Expand All @@ -103,7 +103,7 @@ export default class OneSignal {
}

static promptForPushNotificationsWithUserResponse(callback: Function) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (Platform.OS === 'ios') {
invariant(
Expand All @@ -117,7 +117,7 @@ export default class OneSignal {
}

static requestPermissions(permissions) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

var requestedPermissions = {};
if (Platform.OS === 'ios') {
Expand All @@ -141,23 +141,23 @@ export default class OneSignal {
}

static configure() {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

RNOneSignal.configure();
}

static init(appId, iOSSettings) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (Platform.OS == 'ios') {
RNOneSignal.initWithAppId(appId, iOSSettings);
} else {
RNOneSignal.init(appId);
}
if (Platform.OS == 'ios') {
RNOneSignal.initWithAppId(appId, iOSSettings);
} else {
RNOneSignal.init(appId);
}
}

static checkPermissions(callback: Function) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (Platform.OS === 'ios') {
invariant(
Expand All @@ -171,17 +171,17 @@ export default class OneSignal {
}

static promptForPushNotificationPermissions(callback) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (Platform.OS === 'ios') {
RNOneSignal.promptForPushNotificationPermissions(callback);
} else {
console.log('This function is not supported on Android');
}
if (Platform.OS === 'ios') {
RNOneSignal.promptForPushNotificationPermissions(callback);
} else {
console.log('This function is not supported on Android');
}
}

static getPermissionSubscriptionState(callback: Function) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

invariant(
typeof callback === 'function',
Expand All @@ -191,31 +191,31 @@ export default class OneSignal {
}

static sendTag(key, value) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

RNOneSignal.sendTag(key, value);
}

static sendTags(tags) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

RNOneSignal.sendTags(tags || {});
}

static getTags(next) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

RNOneSignal.getTags(next);
}

static deleteTag(key) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

RNOneSignal.deleteTag(key);
}

static enableVibrate(enable) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (Platform.OS === 'android') {
RNOneSignal.enableVibrate(enable);
Expand All @@ -225,7 +225,7 @@ export default class OneSignal {
}

static enableSound(enable) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (Platform.OS === 'android') {
RNOneSignal.enableSound(enable);
Expand All @@ -235,7 +235,7 @@ export default class OneSignal {
}

static setEmail(email, emailAuthCode, callback) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (emailAuthCode == undefined) {
//emailAuthCode is an optional parameter
Expand All @@ -253,7 +253,7 @@ export default class OneSignal {
}

static logoutEmail(callback) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

invariant(
typeof callback === 'function',
Expand All @@ -264,26 +264,26 @@ export default class OneSignal {
}

static setLocationShared(shared) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

RNOneSignal.setLocationShared(shared);
}

static setSubscription(enable) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

RNOneSignal.setSubscription(enable);
}

static promptLocation() {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

//Supported in both iOS & Android
RNOneSignal.promptLocation();
}

static inFocusDisplaying(displayOption) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (Platform.OS === 'android') {
//Android: Set Display option of the notifications. displayOption is of type OSInFocusDisplayOption
Expand All @@ -296,7 +296,7 @@ export default class OneSignal {
}

static postNotification(contents, data, player_id, otherParameters) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (Platform.OS === 'android') {
RNOneSignal.postNotification(JSON.stringify(contents), JSON.stringify(data), player_id, JSON.stringify(otherParameters));
Expand All @@ -306,7 +306,7 @@ export default class OneSignal {
}

static clearOneSignalNotifications() {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (Platform.OS === 'android') {
RNOneSignal.clearOneSignalNotifications();
Expand All @@ -316,7 +316,7 @@ export default class OneSignal {
}

static cancelNotification(id) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

if (Platform.OS === 'android') {
RNOneSignal.cancelNotification(id);
Expand All @@ -327,34 +327,34 @@ export default class OneSignal {

//Sends MD5 and SHA1 hashes of the user's email address (https://documentation.onesignal.com/docs/ios-sdk-api#section-synchashedemail)
static syncHashedEmail(email) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

RNOneSignal.syncHashedEmail(email);
}

static setLogLevel(nsLogLevel, visualLogLevel) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

RNOneSignal.setLogLevel(nsLogLevel, visualLogLevel);
}

static setRequiresUserPrivacyConsent(required) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

RNOneSignal.setRequiresUserPrivacyConsent(required);
RNOneSignal.setRequiresUserPrivacyConsent(required);
}

static provideUserConsent(granted) {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

RNOneSignal.provideUserConsent(granted);
RNOneSignal.provideUserConsent(granted);
}

static userProvidedPrivacyConsent() {
if (!checkIfInitialized()) return;
if (!checkIfInitialized()) return;

//returns a promise
return RNOneSignal.userProvidedPrivacyConsent();
//returns a promise
return RNOneSignal.userProvidedPrivacyConsent();
}

}

0 comments on commit 801d158

Please sign in to comment.