react-native#PushNotificationIOS JavaScript Examples

The following examples show how to use react-native#PushNotificationIOS. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: notification.ios.js    From RRWallet with MIT License 6 votes vote down vote up
export function checkNotificationPermissions(callback) {
  PushNotificationIOS.checkPermissions(permissions => {
    const { alert, badge, sound } = permissions;
    if (!alert && !badge && !sound) {
      PushEnabled = false;
    } else {
      PushEnabled = true;
    }
    if (callback) {
      callback(PushEnabled);
    }
  });
}
Example #2
Source File: notification.ios.js    From RRWallet with MIT License 5 votes vote down vote up
export function requestNotificationPermissions() {
  PushNotificationIOS.requestPermissions();
  checkNotificationPermissions();
}
Example #3
Source File: notification.ios.js    From RRWallet with MIT License 5 votes vote down vote up
export function setApplicationIconBadgeNumber(number) {
  PushNotificationIOS.setApplicationIconBadgeNumber(number);
}
Example #4
Source File: notification.ios.js    From RRWallet with MIT License 5 votes vote down vote up
PushNotificationIOS.getInitialNotification().then(notification => {
  setTimeout(() => {
    notificationHandler(notification, true);
  }, 1500);
});
Example #5
Source File: notification.ios.js    From RRWallet with MIT License 5 votes vote down vote up
PushNotificationIOS.addEventListener("register", token => {
  pushToken = token;
  console.log("register:" + token);
  setPushToken(token);
  checkNotificationPermissions();
});
Example #6
Source File: notification.ios.js    From RRWallet with MIT License 5 votes vote down vote up
// DeviceEventEmitter.addListener('quickActionShortcut', data => {
//     alert(111)
//     handleQuickAction(data)
// })

PushNotificationIOS.addEventListener("registrationError", (msg, code, details) => {
  console.log("registrationError:" + msg);
});
Example #7
Source File: notification.ios.js    From RRWallet with MIT License 5 votes vote down vote up
PushNotificationIOS.addEventListener("notification", notification => {
  notificationHandler(notification);
});
Example #8
Source File: BackgroundSync.js    From hugin-mobile with GNU Affero General Public License v3.0 5 votes vote down vote up
async function fromHeadlessJSInit() {
    /* See if user has previously made a wallet */
    const hasWallet = await haveWallet();

    if (!hasWallet) {
        Globals.logger.addLogMessage('[Background Sync] No wallet stored. Not starting background sync.');
        return false;
    }

    await openDB();

    const prefs = await loadPreferencesFromDatabase();

    if (prefs !== undefined) {
        Globals.preferences = prefs;
    }

    /* Load wallet data from DB */
    let [walletData, dbError] = await loadWallet();

    if (dbError) {
        Globals.logger.addLogMessage('[Background Sync] Failed to load wallet. Not starting background sync.');
        return false;
    }

    const [wallet, walletError] = await WalletBackend.loadWalletFromJSON(
        Globals.getDaemon(), walletData, Config
    );

    if (walletError) {
        Globals.logger.addLogMessage('[Background Sync] Failed to load wallet. Not starting background sync.');
        return false;
    }

    Globals.wallet = wallet;

    Globals.wallet.scanCoinbaseTransactions(Globals.preferences.scanCoinbaseTransactions);
    Globals.wallet.enableAutoOptimization(false);

    /* Remove any previously added listeners to pretend double notifications */
    Globals.wallet.removeAllListeners('incomingtx');

    Globals.wallet.on('incomingtx', (transaction) => {
        sendNotification(transaction);
    });

    Globals.wallet.setLoggerCallback((prettyMessage, message) => {
        Globals.logger.addLogMessage(message);
    });

    Globals.wallet.setLogLevel(LogLevel.DEBUG);

    /* Use our native C++ func to process blocks, provided we're on android */
    /* TODO: iOS support */
    if (Platform.OS === 'android') {
        Globals.wallet.setBlockOutputProcessFunc(processBlockOutputs);
    }

    PushNotification.configure({
        onNotification: (notification) => {
            notification.finish(PushNotificationIOS.FetchResult.NoData);
        },

        permissions: {
            alert: true,
            badge: true,
            sound: true,
        },

        popInitialNotification: true,

        requestPermissions: true,
    });

    return true;
}