React native 和 onesignal 通知问题
React native and onesignal notification problem
你好,首先我学习了 react-native 并且我使用 onesignal 来通知所有很棒的东西但是
有时 iphone 6s 没有令牌一个信号错误是 '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
- 检查 6s 和 6plus 之间的 os 版本。
- 如果应用程序是前台,通知将显示在屏幕上,如果应用程序是后台,通知将显示在屏幕上方。
编辑
将此代码添加到您的 AppDelegate.m
(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"didFailToRegisterForRemoteNotificationsWithError %@", error);
}
kOSSettingsKeyInFocusDisplayOption=2 我添加了这段代码,通知将显示为正常通知。
你好,首先我学习了 react-native 并且我使用 onesignal 来通知所有很棒的东西但是
有时 iphone 6s 没有令牌一个信号错误是 '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
- 检查 6s 和 6plus 之间的 os 版本。
- 如果应用程序是前台,通知将显示在屏幕上,如果应用程序是后台,通知将显示在屏幕上方。
编辑
将此代码添加到您的 AppDelegate.m
(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"didFailToRegisterForRemoteNotificationsWithError %@", error);
}
kOSSettingsKeyInFocusDisplayOption=2 我添加了这段代码,通知将显示为正常通知。