簡體   English   中英

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

  1. 在 6s 和 6plus 之間檢查您的操作系統版本。
  2. 如果應用程序是前台,通知將顯示在您的屏幕上,如果應用程序是后台,則通知將顯示在您的屏幕上。

編輯將此代碼添加到您的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