gpt4 book ai didi

ios - React Native Expo 弹出应用程序,无法从设备获取推送 token

转载 作者:行者123 更新时间:2023-11-29 05:11:07 25 4
gpt4 key购买 nike

我使用 Expo 推送通知通过推送 token 将通知发送到 GSM。我的代码是:

  registerForPush = async () => {
if (Constants.isDevice) {
const { status: existingStatus } = await Permissions.getAsync(
Permissions.NOTIFICATIONS,
);
let finalStatus = existingStatus;
if (existingStatus !== 'granted') {
const { status } = await Permissions.askAsync(
Permissions.NOTIFICATIONS,
);
finalStatus = status;
}
if (finalStatus !== 'granted') {
alert('Failed to get push token for push notification!');
return;
}
const gsm = await Notifications.getExpoPushTokenAsync();
this._storeData('TOKEN_GSM', gsm);
} else {
alert('Must use physical device for Push Notifications');
}
};

async componentDidMount() {
this.registerForPush();
}

当我使用 Expo 运行应用程序时,我手动授予了获取 token 的权限,但现在我弹出到应用程序以使用 Xcode 运行 IOS 项目。我收到一个错误,无法获取推送 token :无法获取推送通知的推送 token

最佳答案

世博会被拒绝的应用程序需要使用react-native库来进行通知。我推荐:https://github.com/zo0r/react-native-push-notification

目前有博览会套件解决方案。但这些很快就会贬值,取而代之的是纯粹的工作流程。 https://blog.expo.io/expo-sdk-34-is-now-available-4f7825239319

Deprecating ExpoKit in favor of the bare workflow. We’re continuing to invest in building tooling and documentation around the bare workflow. We believe that this workflow is strictly better than ExpoKit and has lots of advantages for developers, such as full compatibility with libraries in the React Native ecosystem, easier upgrades, and more modular native code that doesn’t include all of the libraries in the Expo monolith. The bare workflow is the easiest and quickest way to achieve optional modules — that is, including native code for only the Expo modules you actually use.

关于ios - React Native Expo 弹出应用程序,无法从设备获取推送 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59680723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com