How to use the react-native-intercom.sendTokenToIntercom function in react-native-intercom

To help you get started, we’ve selected a few react-native-intercom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pillarwallet / pillarwallet / src / actions / authActions.js View on Github external
wallet = { ...encryptedWallet, privateKey, address: walletAddress };
      } else {
        // nothing provided, invalid login
        throw new Error();
      }

      const network = findEthereumNetwork(ethereumNetwork);
      dispatch(setEthereumNetwork(network));

      let { user = {} } = await storage.get('user');
      const userState = user.walletId ? REGISTERED : PENDING;
      if (userState === REGISTERED) {
        const fcmToken = await firebase.messaging().getToken().catch(() => null);
        dispatch({ type: UPDATE_SESSION, payload: { fcmToken } });

        await Intercom.sendTokenToIntercom(fcmToken).catch(() => null);
        const signalCredentials = {
          userId: user.id,
          username: user.username,
          walletId: user.walletId,
          ethAddress: wallet.address,
          fcmToken,
        };
        const updateOAuth = updateOAuthTokensCB(dispatch, signalCredentials);
        const onOAuthTokensFailed = onOAuthTokensFailedCB(dispatch);
        api.init(updateOAuth, oAuthTokens, onOAuthTokensFailed, network);

        if (onLoginSuccess && wallet.privateKey) {
          let { privateKey: privateKeyParam } = wallet;
          privateKeyParam = privateKeyParam.indexOf('0x') === 0 ? privateKeyParam.slice(2) : privateKeyParam;
          await onLoginSuccess(privateKeyParam);
        }
github pillarwallet / pillarwallet / src / actions / onboardingActions.js View on Github external
const getTokenWalletAndRegister = async (
  privateKey: string,
  api: Object, // FIXME: this should be api: SDKWrapper
  user: Object,
  dispatch: Dispatch,
) => {
  await firebase.messaging().requestPermission().catch(() => { });
  const fcmToken = await firebase.messaging().getToken().catch(() => { });

  await Intercom.sendTokenToIntercom(fcmToken).catch(() => null);
  const sdkWallet = await api.registerOnAuthServer(privateKey, fcmToken, user.username);
  const registrationSucceed = !sdkWallet.error;
  const userInfo = await api.userInfo(sdkWallet.walletId);
  const userState = Object.keys(userInfo).length ? REGISTERED : PENDING;

  if (Object.keys(userInfo).length) {
    dispatch(saveDbAction('user', { user: userInfo }, true));
  }

  const oAuthTokens = {
    refreshToken: sdkWallet.refreshToken,
    accessToken: sdkWallet.accessToken,
  };

  const updateOAuth = updateOAuthTokensCB(dispatch);
  await updateOAuth(oAuthTokens);