在禁用通知的 Mac Catalyst 中调用 registerRemoteNotificationsRegistered() 或 registerRemoteNotificationsRegistrationFailed()

问题描述

如果用户在 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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...