【发布时间】:2014-01-29 19:31:55
【问题描述】:
我们的应用是使用 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