Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 添加AppDelegate后,应用程序为空_Ios_Objective C_Onesignal - Fatal编程技术网

Ios 添加AppDelegate后,应用程序为空

Ios 添加AppDelegate后,应用程序为空,ios,objective-c,onesignal,Ios,Objective C,Onesignal,我在Cordova有一个iOS应用程序,使用OneSignal实现推送通知 我已经遵循了文档中的所有步骤 问题是,当我使用XCode安装应用程序时,应用程序会询问 AppName希望向您发送通知 但在那之后,一切都变成了黑屏 我假设这是因为AppDelegate.m文件,它是 /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See th

我在Cordova有一个iOS应用程序,使用OneSignal实现推送通知

我已经遵循了文档中的所有步骤

问题是,当我使用XCode安装应用程序时,应用程序会询问

AppName希望向您发送通知

但在那之后,一切都变成了黑屏

我假设这是因为AppDelegate.m文件,它是

/*
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 */

//
//  AppDelegate.m
//  ReachApp
//
//  Created by ___FULLUSERNAME___ on ___DATE___.
//  Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//

#import "AppDelegate.h"
#import "MainViewController.h"

#import <OneSignal/OneSignal.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Replace '11111111-2222-3333-4444-0123456789ab' with your OneSignal App ID.
    [OneSignal initWithLaunchOptions:launchOptions
                               appId:@"11111111-2222-3333-4444-0123456789ab"
            handleNotificationAction:nil
                            settings:@{kOSSettingsKeyAutoPrompt: @false}];
    OneSignal.inFocusDisplayType = OSNotificationDisplayTypeNotification;

    // Recommend moving the below line to prompt for push after informing the user about
    //   how your app will use them.
    [OneSignal promptForPushNotificationsWithUserResponse:^(BOOL accepted) {
        NSLog(@"User accepted notifications: %d", accepted);
    }];

    return YES;
}

@end
/*
授权给Apache软件基金会(ASF)
一个或多个参与者许可协议。见通知文件
与此工作一起分发以获取更多信息
关于版权所有权。ASF许可此文件
根据Apache许可证,版本2.0(
“许可证”);除非符合规定,否则您不得使用此文件
带着执照。您可以通过以下方式获得许可证副本:
http://www.apache.org/licenses/LICENSE-2.0
除非适用法律要求或书面同意,
根据许可证分发的软件在
“按原样”的基础上,没有任何
种类,无论是明示的还是暗示的。请参阅许可证以获取详细信息
管理权限和限制的特定语言
根据许可证。
*/
//
//AppDelegate.m
//重新发生
//
//由日期为的完整用户名创建。
//版权所有组织名称年。版权所有。
//
#导入“AppDelegate.h”
#导入“MainViewController.h”
#进口
@实现AppDelegate
-(BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项{
//将“11111111-2222-3333-4444-0123456789ab”替换为您的OneSignal应用程序ID。
[OneSignal initWithLaunchOptions:启动选项
附件:@“11111111-2222-3333-4444-0123456789ab”
HandleNotification操作:无
设置:@{kossettingskeyayautoprompt:@false}];
OneSignal.inFocusDisplayType=OSNotificationDisplayTypeNotification;
//建议在通知用户后移动下面的行以提示推送
//你的应用程序将如何使用它们。
[One Signal Prompt for Push Notifications SwithUserResponse:^(接受BOOL){
NSLog(@“用户接受的通知:%d”,已接受);
}];
返回YES;
}
@结束
我也换了身份证。在XCode日志中,它很少显示警告,这是

2018-06-29 12:33:16.661 ReachApp[721:311194]磁盘存储 将策略从2更改为0,cookie文件: file:///private/var/mobile/Containers/Data/Application/4C0D3ECB-1F40-4668-BE78-AE1EF3CB7810/Library/Cookies/Cookies.binarycookies 2018-06-29 12:33:16.838 ReachApp[721:311194]调用了应用程序ID为的初始化: (null)2018-06-29 12:33:16.934 ReachApp[721:311194]调用了init 应用程序ID:此处显示实际应用程序ID 2018-06-29 12:33:17.019 ReachApp[721:311194]警告:OneSignal检测到您的 应用程序委托实现了一个不推荐使用的方法 (应用程序:didReceiveLocalNotification:)。请注意 方法已被正式弃用,OneSignal SDK将不会 别再叫它了。您应该改用UnuseNotificationCenter 2018-06-29 12:33:17.020再次发生[721:311194]警告:OneSignal已 检测到您的应用程序委托实现了一个不推荐使用的方法 (应用程序:handleActionWithIdentifier:forLocalNotification:completionHandler:)。 请注意,此方法已被正式弃用,并且 OneSignal SDK将不再调用它。你应该使用 改为联合国信息中心2018-06-29 12:33:17.020 ReachApp[721:311194]警告:OneSignal检测到您的 应用程序委托实现了一个不推荐使用的方法 (应用程序:didReceiveLocalNotification:)。请注意 方法已被正式弃用,OneSignal SDK将不会 别再叫它了。您应该改用UnuseNotificationCenter 2018-06-29 12:33:17.028再次发生[721:311194]警告:OneSignal已 检测到您的应用程序委托实现了一个不推荐使用的方法 (应用程序:handleActionWithIdentifier:forLocalNotification:completionHandler:)。 请注意,此方法已被正式弃用,并且 OneSignal SDK将不再调用它。你应该使用 取而代之的是联合国信息中心


请添加以下方法来处理appdelegate中的通知

   -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    NSLog(@"Application registered for notification");
}

-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
    NSLog(@"Failed to register notification for application");
}

-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{

}

-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{

}

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{

}

我认为有两个不同的问题。空白屏幕问题的原因可能是应用程序不知道要显示哪个视图控制器。如果您使用的是故事板,则可以将所需的视图控制器设置为“初始视图控制器”

或者你可以加上

self.window.rootViewController=self.viewController;
[self.window makeKeyAndVisible]

截至:

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions

就在上面
返回YES

能否请您提供目标-C的相关代码。我已在AppDelegate中添加了代码,但仍然没有差异屏幕变黑。是的,xcode警告仍然存在。我发布的代码是AppDelegate的完整代码。请更改应用程序设置。转到设置->应用程序->通知->允许通知-设置