Устройство не смогло зарегистрировать удаленные уведомления в Apple даже в автономном режиме - PullRequest
0 голосов
/ 24 апреля 2019

У меня есть отдельное приложение (Expo) в App Store. Когда я пытаюсь получить Экспо Push Token, я получаю эту ошибку:

Error: The device was unable to register for remote notifications with Apple

Я не запускаю это на симуляторе iOS. Они с настоящих айфонов, запускающих приложение из App Store.

Это ошибка InvalidCredentials? Что мне нужно сделать, чтобы решить эту проблему?

Я исследовал переполнение стека и перепробовал множество перестановок этого метода, но ничего не работает.

Похоже, что этот метод отлично работает и для Android.

import * as str from './index';
import axios from 'axios';

import { Permissions, Notifications } from 'expo';

export async function registerForPushNotificationsAsync(token) {

  // Getting the status for this device
  const { status: existingStatus } = await Permissions.getAsync(
    Permissions.NOTIFICATIONS
  );
  let finalStatus = existingStatus;

  // Only ask if permissions have not already been determined, for iOS.
  if (existingStatus !== 'granted') {
    const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
    finalStatus = status;
  }

  // Post new push token to backend for user
  if(finalStatus !== 'granted'){
    return;
  }

  // Get the push token that uniquely identifies this device
  Notifications.getExpoPushTokenAsync()

  // Post the success
  .then(response => {
    axios({
      method: 'POST',
      url: `${str.ROOT_URL}/account/push/`,
      headers: {
        Authorization: `Token ${token}`
      },
      data: {
        "token": response,
        "status": finalStatus
      }
    });
    dispatch({ type: 'nothing' })
  })

  // Post the error
  .catch(error => {
    console.log(error.toString()) // THIS IS WHERE THE MESSAGE COMES
    dispatch({ type: 'nothing' })
  });

}
...