问题描述
如果用户在 Mac Catalyst 应用的系统偏好设置中关闭了“允许通知”开关,则不会调用回调(...Registered
或 ...RegistrationFailed
),因此应用不会收到任何通知关于远程通知是否有效的反馈。
一种解决方法是还使用 react-native-permissions 并调用该模块的 requestNotifications()
函数。这真的是一种“解决方法”还是只是预期的用法?
(注意 - 无论是否存在我们对 requestPermissions()
的手动调用,都会调用本机代码中的 requestNotifications()
函数,似乎任何地方都没有考虑到该函数的错误)
这是我们的用法(简化版)
export const useRemoteNotifications = () => {
useEffect(() => {
// our workaround call to Permissions.requestNotifications().then(whatever) happens here
const registeredSub = Notifications.events().registerRemoteNotificationsRegistered(
// register the device with our API
);
const registrationFailedSub = Notifications.events().registerRemoteNotificationsRegistrationFailed(
// alert the user the app doesn't work great without push notifications
);
return () => {
registeredSub.remove();
registrationFailedSub.remove();
};
}
};
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)