• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 使用 PushNotificationIOS 时没有已知的选择器类方法

[复制链接]
菜鸟教程小白 发表于 2022-12-13 13:44:59 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在尝试让推送通知在我的 React Native iOS 应用程序中工作。我正在关注教程 PushNotificationsIOS .我也手动链接了库。

PushNotificationIOS Library

在AppDelegate.m文件中看起来如下,

/**
 * 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)applicationUIApplication *)application didRegisterUserNotificationSettingsUIUserNotificationSettings *)notificationSettings
{
  [RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
}
// Required for the register event.
- (void)applicationUIApplication *)application didRegisterForRemoteNotificationsWithDeviceTokenNSData *)deviceToken
{
  [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event.
- (void)applicationUIApplication *)application didReceiveRemoteNotificationNSDictionary *)notification
{
  [RCTPushNotificationManager didReceiveRemoteNotification:notification];
}

- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)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 = [NSURL URLWithString"http://172.16.2.173:8081/index.ios.bundle?platform=ios&dev=true"];

  jsCodeLocation = [NSURL URLWithString"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

  /**
   * 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 = [[NSBundle mainBundle] URLForResource"main" withExtension"jsbundle"];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName"myapp"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

@end

但是构建失败并出现错误,

No known class method for selector 'didRegisterUserNotificationSettings:'
No known class method for selector 'didRegisterForRemoteNotificationsWithDeviceToken:'
No known class method for selector 'didReceiveRemoteNotification:'

这是为什么?如何解决这个问题?


PS:注意

找到了一个替代方案,效果很好。 Apple Push Notification Services in iOS 6 Tutorial



Best Answer-推荐答案


请遵循非常简单的 raywenderlich 教程。 APNS Tutorial 希望对您有所帮助。

关于ios - 使用 PushNotificationIOS 时没有已知的选择器类方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34985677/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap