Bugtags的使用463.com:

iOS 监测应用是否是第一次打开&监测应用是否已经更新

解决方案:在AppDelegate.h中的didFinishLaunchingWithOptions里面添加:

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    NSLog(@did Finish Launching With Options);

    if ([[NSUserDefaults standardUserDefaults] boolForKey:@isFirstLaunched]){
        NSLog(@AppDelegate - didFinishLaunchingWithOptions: App was already launched.);
    }
    else{
        NSLog(@AppDelegate - didFinishLaunchingWithOptions: App's first launch.);

        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@isFirstLaunched];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }

    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@clientVersion] isEqualToString:CLIENT_VERSION]) {
        NSLog(@AppDelegate - didFinishLaunchingWithOptions: App version remains the same.);
    }
    else{
        NSLog(@AppDelegate - didFinishLaunchingWithOptions: App version did update.);
        [[NSUserDefaults standardUserDefaults] setObject:CLIENT_VERSION forKey:@clientVersion];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }

    return YES;
}

 

 

在App-Prefix.pch中定义CLIENT_VERSION:

 

    #define CLIENT_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@CFBundleShortVersionString]

 

 

 

 

http://www.bkjia.com/IOSjc/887796.htmlwww.bkjia.comtruehttp://www.bkjia.com/IOSjc/887796.htmlTechArticleiOS
监测应用是否是第一次打开amp;监测应用是否已经更新 解决方案
:在AppDelegate.h中的didFinishLaunchingWithOptions里面添加: –
(BOOL)application:(U…

在你项目的 Podfile 中添加以下代码

pod 'Bugtags'

执行 pod 安装命令

pod install

如果无法获取到最新版本的 Bugtags SDK,请运行以下命令更新本地的 pod 仓库

pod repo update

运行完成后,重新执行安装命令

pod install

重要! 执行完 pod 命令后,请确认在应用对应 target 的设置中,Build
Settings -> Linking 项下的 Other Linker Flags 中是否已自动添加
$(inherited),如果未添加,请手动添加 Other Linker Flags

在 AppDelegate.m 中导入头文件

#import <Bugtags/Bugtags.h>

如果是 Swift 项目,请在对应的 bridging-header.h 中导入
在项目 AppDelegate 的 application didFinishLaunchingWithOptions
方法中初始化 Bugtags(请不要在异步线程中调用)

Objective-C

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

     [Bugtags startWithAppKey:@"a3d6e7ef6a633fda695f30535d9b4674" invocationEvent:BTGInvocationEventBubble];
     return YES;
 }

Swift

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

     Bugtags.startWithAppKey("a3d6e7ef6a633fda695f30535d9b4674", invocationEvent: BTGInvocationEventBubble)
     return true
 }

相关文章