AppDelegate.m中不存在didFinishLaunchingWithOptions方法(Cordova 2.3.0)

问题描述 投票:1回答:1

我们的应用程序是使用Cordova / Phonegap为iOS构建的,我们正在尝试添加一些第三方库以进行应用程序性能监控。由于我们的应用程序也使用Salesforce Hybrid SDK,因此我们目前无法升级Cordova,因此我们的版本停留在2.3.0。我们所看到的所有服务都需要在AppDelegate.m中的didFinishLaunchingWithOptions方法中加载和初始化他们的SDK。例如,一个库的快速启动说明如下所示:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // other code for your app
    // ...
    [Crittercism enableWithAppID: @"52e9510d4002056e4300000b"];
}

我能够毫无问题地包含头文件,但是框架提供的AppDelegate.m中不存在这个应该存在的方法。当我尝试将自己的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法添加到AppDelegate.h和AppDelegate.m时,Phonegap容器永远不会加载,应用程序只会挂起黑屏。有没有其他方法可以将此方法添加到我的AppDelegate,或者Cordova是否有另一个地方可以加载和初始化第三方库,如crittercism?将Cordova升级到最新版本不是一种选择。作为参考,我目前拥有的完整AppDelegate.m实现是:

#import "AppDelegate.h"

@implementation AppDelegate

#pragma mark - App lifecycle

+ (NSString *) startPage
{
    NSString *superValue = [super startPage];
    return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"test"] ? @"test.html" : superValue;
};

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)w {
    return (NSUInteger)[application supportedInterfaceOrientationsForWindow:w] | (1<<UIInterfaceOrientationPortrait);
}
// NOTE: be sure to call all super methods you override.

@end
ios objective-c cordova appdelegate
1个回答
1
投票

刚刚意识到我在没有调用其原始实现的情况下重写了didFinishLaunchingWithOptions。修复了将[super application:application didFinishLaunchingWithOptions:launchOptions];添加到我的实现中。

© www.soinside.com 2019 - 2024. All rights reserved.