swift - 方法“应用程序:didRegisterUserNotificationSettings:”的重复声明
问题描述
我正在使用 react native 处理“react-native-firebase”:“^5.5.6”和“react-native-push-notification”:“^3.1.9”,但我遇到了错误 Duplicate declaration of method appDelegate.m 上的“应用程序:didRegisterUserNotificationSettings:”
我尝试了通过网络找到的各种解决方案,如果我评论其中一种方法,我会收到错误“本机模块不能为空”
- (void)application:(UIApplication *)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings
*)notificationSettings {
[[RNFirebaseMessaging instance]
didRegisterUserNotificationSettings:notificationSettings];
}
// Required to register for notifications
- (void)application:(UIApplication *)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings
*)notificationSettings
{
[RCTPushNotificationManager
didRegisterUserNotificationSettings:notificationSettings];
}
我的代码中需要这两种方法而没有任何错误。我也可以使用 if else 或其他解决方案,但由于我是这项技术的新手,因此将不胜感激。提前致谢!
解决方案
我不建议混合功能,但试试这个:
- (void)application:(UIApplication *)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings
*)notificationSettings {
[[RNFirebaseMessaging instance]
didRegisterUserNotificationSettings:notificationSettings];
[RCTPushNotificationManager
didRegisterUserNotificationSettings:notificationSettings];
}
所以你用同样的方法初始化两者。同样,不知道为什么你需要两者,你应该尽量只保留一个。
推荐阅读
- python - 二进制编码的标签列表
- plsql - Line/Col:2/10 PLS-00103:在预期以下情况之一时遇到符号“JOBS_PKG”:
- java - 如何使用 firebase 获取 listView 中每个项目的数据?
- azure - 在多个环境中配置自托管 Azure API 门户
- jdbc - oracle.ucp.jdbc.PoolDataSource.getConnection() 多线程安全吗?
- remote-access - 拥有远程系统的所有凭据,导航到远程系统上的一个已知应用程序,点击该应用程序并远程获取 ScreenShoot
- python - HID 记忆棒上的自动执行程序
- python - 如何自动进行词性标注和词形还原
- iot - SIM800L和电机驱动器如何一起供应?
- javascript - 建立类似于 Youtube 播放器的设置菜单