react-native - 什么是 AppDelegate 实现?推送通知IOS

标签 react-native

这方面的文档不清楚。

https://facebook.github.io/react-native/docs/pushnotificationios.html

And then in your AppDelegate implementation add the following:



是指把这个代码放在@implementation AppDelegate下面吗?像这样:
#import "RCTPushNotificationManager.h"
#import "AppDelegate.h"
#import "RCTRootView.h"

@implementation AppDelegate

// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { [RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings]; }  // Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; }  // Required for the notification event.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification { [RCTPushNotificationManager didReceiveRemoteNotification:notification]; }  // Required for the localNotification event.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [RCTPushNotificationManager didReceiveLocalNotification:notification]; } - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { NSLog(@"%@", error); }

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{
  NSURL *jsCodeLocation;

  ...
}

@end

谢谢!

最佳答案

是的,它应该在 AppDelegate 中的 @implementation 内。

这是我在使用 PushNotificationIOS 的应用程序中的 AppDelegate.m
My AppDeligate.m

关于react-native - 什么是 AppDelegate 实现?推送通知IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38375581/

相关文章:

android - 无法在 Android Studio 中调试 React Native

javascript - React navigation 5从堆栈导航器中隐藏标签栏

react-native - 如何使用 Expo 获取 FB Access Token

javascript - 父组件或子组件应该在 React 中获取数据吗?

android - FaSTLane 分发失败,错误为 "App Distribution could not find your app"

ios - 在 AppCenter 上构建的 iOS 上找不到相关 ID 错误

firebase - React Native - 将图像上传到 Firebase 存储

ios - 初始化React Native应用程序时出现不受支持的架构错误

android - React Native 同步安全随机数生成

button - 如何在 react 原生的按钮上滚动顶部?