ios - 在 React Native 前台设置 PushNotificationIOS 时发出警告

标签 ios objective-c react-native react-native-ios

setting up foreground push notification on IOS 时,我在 Xcode 上收到以下警告:

Assigning to 'id<UNUserNotificationCenterDelegate> _Nullable' 
from incompatible type 'AppDelegate *const __strong'

此警告出现在此代码段的最后一行:

// Define UNUserNotificationCenter
  UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  center.delegate = self;

我的应用程序按预期编译并运行。我没有使用 Objective-C 的经验,所以我不知道这是什么。怎么解决呢?

最佳答案

我遇到了同样的问题,并通过将 UNUserNotificationCenterDelegate 添加到我的 AppDelegate 接口(interface)来解决它:

@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>

关于ios - 在 React Native 前台设置 PushNotificationIOS 时发出警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58022324/

相关文章:

objective-c - 修复UILabel的边框

android - HostObject::get 中的异常:<unknown> - React Native Build Android

react-native - 如何使用 Share() 在 react-native 中共享应用程序的 URL 链接?

iphone - iOS 许多图像 - 保持良好的性能

iphone - 从模拟方法崩溃返回 CGRect

ios - 无法从 bool 条件显示 UILabel

ios - UILabel 属性文本未更改

react-native-router-flux 抛出 Actions.callback 未定义

ios - 对象映射到根 Json 返回 nil

如果在录音或通话期间状态栏增加,iOS 自定义键盘的框架会缩小 20 点?