简体   繁体   English

React native 和 onesignal 通知问题

[英]React native and onesignal notification problem

Hi firstly I learning react-native and I use onesignal for notification everything awesome but sometimes iphone 6s hasnt token one signal error is 'Apns Delegate Never Fired' but 6 plus alwasy has a token and background notification very nice.嗨,首先我学习 react-native,我使用 onesignal 来通知一切都很棒,但有时 iphone 6s 没有标记一个信号错误是“Apns Delegate Never Fired”,但 6 plus 总是有一个非常好的标记和背景通知。 If the application is open while sending a notification, the notification does not occur above.如果在发送通知时应用程序处于打开状态,则上述通知不会发生。 It occurs on a dialog screen.它发生在对话屏幕上。 像这样

 /** * 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

  1. check your os version between on 6s and 6plus.在 6s 和 6plus 之间检查您的操作系统版本。
  2. If the app is foreground,notification will show on your screen, if the app is background,notification will show above.如果应用程序是前台,通知将显示在您的屏幕上,如果应用程序是后台,则通知将显示在您的屏幕上。

EDIT add this code to your AppDelegate.m编辑将此代码添加到您的AppDelegate.m

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM