Push-уведомления не работают после развертывания приложения Expo в Apple Store TestFlight - PullRequest
0 голосов
/ 07 июля 2019

Push-уведомления прекрасно работают на моем телефоне с iOS. Я могу получить токен и успешно сохранить его и вызвать из моей базы данных Google Firestore. Напомним, что отправка уведомлений также работает как ожидалось. Если я не в приложении, я получаю уведомление. Если я в приложении, мой слушатель уведомлений работает хорошо.

После сборки на iOS и развертывания автономного приложения в TestFlight на серверах Apple, Push-уведомления больше не работают.

Это моя сборка.

Adrians-MBP:xxxxx abarthol$ expo build:ios -c
Checking if there is a build in progress...

Removed existing credentials from expo servers
Please enter your Apple Developer Program account credentials. These
credentials are needed to manage certificates, keys and provisioning profiles
in your Apple Developer account.
The password is only used to authenticate with Apple and never stored.
? Apple ID: xxxxx
? Password (for xxxxx): [hidden]
Trying to authenticate with Apple Developer Portal...
Authenticated with Apple Developer Portal successfully!
Only 1 team associated with your account, using Apple Team with ID: xxxxx
We do not have some credentials for you: Apple Distribution Certificate, Apple Push Notifications service key, Apple Provisioning Profile
? How would you like to upload your credentials? Expo handles all credentials, y
ou can still provide overrides
? Will you provide your own Apple Distribution Certificate? Let Expo handle the 
process
✔ Didn't find any previously uploaded Apple Distribution Certificate
? Will you provide your own Apple Push Notifications service key? I want to uplo
ad my own file
Please provide your Apple Push Notifications service key:
? Path to P8 file: ~/Sites/certs/aps.cer
? Key ID: xxxxx
✔ App ID found on Apple Developer Portal.
We're going to generate:
- Apple Distribution Certificate
- Apple Provisioning Profile
✔ Generated Apple Distribution Certificate
✔ Generated Apple Provisioning Profile
Encrypted credentials and saved to the Expo servers
Publishing to channel 'default'...
Building iOS bundle
Building Android bundle
Analyzing assets
Uploading assets
No assets changed, skipped.
Processing asset bundle patterns:
- ~/Sites/Personal/xxxxx/**/*
Uploading JavaScript bundles
Published
Your URL is

https://exp.host/@xxxxx/xxxxx

Checking if this build already exists...

Build started, it may take a few minutes to complete.
You can check the queue length at https://expo.io/turtle-status

You can monitor the build at

 https://expo.io/builds/xxxxx

Waiting for build to complete. You can press Ctrl+C to exit.
✔ Build finished.
Successfully built standalone app: https://expo.io/artifacts/xxxxx

Вот мой компонент:

  componentDidMount() {
    this.registerForPushNotifications();
  }

  componentWillUnmount() {
    if (!this.subscription) return;
    this.subscription.remove();
  }

  registerForPushNotifications = async () => {
    const PNToken = await this.props.MainStore.getLocal("PNToken");
    if (!PNToken) {
      try {
        const { status } = await Permissions.getAsync(
          Permissions.NOTIFICATIONS
        );
        let finalStatus = status;
        if (status !== "granted") {
          const { status } = await Permissions.askAsync(
            Permissions.NOTIFICATIONS
          );
          finalStatus = status;
          if (finalStatus !== "granted") {
            throw "Notification permission not granted";
          }
          const token = await Notifications.getExpoPushTokenAsync();
          this.props.MainStore.setPNToken(token);
          this.subscription = Notifications.addListener(
            this.handleNotification
          );
        }
      } catch (err) {
        console.warn("Permissions check error: ", err);
      }
    } else {
      this.props.MainStore.setPNToken(PNToken);
      this.subscription = Notifications.addListener(this.handleNotification);
    }
  };

  handleNotification = notification => {
    const store = this.props.NotificationStore;
    const sortedNotifications = sortMessages([
      ...store.state.notifications,
      { ...notification, read: false }
    ]);
    store.setState({
      notifications: sortedNotifications
    });
  };

1 Ответ

0 голосов
/ 08 июля 2019

Судя по всему, вы предоставляете старый сертификат APNS компании Expo, когда он запрашивает новый формат P8.

Вы сможете создать новый файл P8 из центра участников Apple.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...