【问题标题】:React native and onesignal notification problemReact native 和 onesignal 通知问题
【发布时间】:2020-03-04 16:07:53
【问题描述】:

嗨,首先我学习了 react-native,我使用 onesignal 来通知一切都很棒但是 有时 iphone 6s hasnt token 一个信号错误是“Apns Delegate Never Fired”,但 6 plus 总是有一个非常好的令牌和背景通知。如果在发送通知时应用程序处于打开状态,则上述通知不会发生。它出现在对话框屏幕上。

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"doyurunbenicomproje"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

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

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end

【问题讨论】:

    标签: ios react-native notifications onesignal


    【解决方案1】:
    1. 在 6s 和 6plus 之间检查您的操作系统版本。
    2. 如果应用是前台,通知会显示在屏幕上,如果应用是后台,通知会显示在上方。

    编辑 将此代码添加到您的AppDelegate.m

     (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
    {
        NSLog(@"didFailToRegisterForRemoteNotificationsWithError %@", error);
    }
    

    【讨论】:

    • 1 .6 plus ios 12 6 s 13 但是昨天 6s 有 token 现在还没有 2。在使用 react native 制作的应用程序中,通知总是出现在上方
    • 我添加了我的代码,但我从不更改应用程序委托,因为一个信号不需要更改应用程序委托代码我只使用此文档 ios documentation.onesignal.com/docs/react-native-sdk-setup
    • 我有解决办法
    【解决方案2】:

    kOSSettingsKeyInFocusDisplayOption=2 我添加了此代码,通知将显示为正常通知。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-10
      相关资源
      最近更新 更多