ios - 使用 PushNotificationIOS 时没有已知的选择器类方法
<p><p>我正在尝试让推送通知在我的 React Native iOS 应用程序中工作。我正在关注教程 <a href="https://facebook.github.io/react-native/docs/pushnotificationios.html" rel="noreferrer noopener nofollow">PushNotificationsIOS</a> .我也手动链接了库。</p>
<p> <a href="/image/c9AKn.png" rel="noreferrer noopener nofollow"><img src="/image/c9AKn.png" alt="PushNotificationIOS Library"/></a> </p>
<p>在AppDelegate.m文件中看起来如下,</p>
<pre><code>/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTPushNotificationManager.h"
#import "AppDelegate.h"
#import "RCTRootView.h"
@implementation AppDelegate
// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
;
}
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
;
}
// Required for the notification event.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification
{
;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
/**
* Loading JavaScript code - uncomment the one you want.
*
* OPTION 1
* Load from development server. Start the server from the repository root:
*
* $ npm start
*
* To run on device, change `localhost` to the IP address of your computer
* (you can get this by typing `ifconfig` into the terminal and selecting the
* `inet` value under `en0:`) and make sure your computer and iOS device are
* on the same Wi-Fi network.
*/
//jsCodeLocation = ;
jsCodeLocation = ;
/**
* OPTION 2
* Load from pre-bundled file on disk. The static bundle is automatically
* generated by "Bundle React Native code and images" build step.
*/
//jsCodeLocation = [ URLForResource:@"main" withExtension:@"jsbundle"];
RCTRootView *rootView = [ initWithBundleURL:jsCodeLocation
moduleName:@"myapp"
initialProperties:nil
launchOptions:launchOptions];
self.window = [ initWithFrame:.bounds];
UIViewController *rootViewController = ;
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
;
return YES;
}
@end
</code></pre>
<p>但是构建失败并出现错误,</p>
<pre><code>No known class method for selector 'didRegisterUserNotificationSettings:'
No known class method for selector 'didRegisterForRemoteNotificationsWithDeviceToken:'
No known class method for selector 'didReceiveRemoteNotification:'
</code></pre>
<p>这是为什么?如何解决这个问题?</p>
<hr/>
<p><strong>PS:注意</strong></p>
<p>找到了一个替代方案,效果很好。 <a href="http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1" rel="noreferrer noopener nofollow">Apple Push Notification Services in iOS 6 Tutorial</a> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>请遵循非常简单的 raywenderlich 教程。
<a href="http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1" rel="noreferrer noopener nofollow">APNS Tutorial</a>
希望对您有所帮助。</p></p>
<p style="font-size: 20px;">关于ios - 使用 PushNotificationIOS 时没有已知的选择器类方法,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/34985677/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/34985677/
</a>
</p>
页:
[1]