UserSwitch 0.0.7

UserSwitch 0.0.7

许可 Apache 2
发布最新发布2017年4月

Adam Cooper 维护。



UserSwitch iOS SDK

UserSwitch iOS SDK支持在 http://www.userswitch.com 上展示的产品

如果您没有开发者账号,请在此处注册一个:注册

安装和配置UserSwitch iOS SDK

步骤 1

UserSwitch通过CocoaPods提供。要安装它,只需将以下行添加到您的Podfile

pod 'UserSwitch'

步骤 2

添加到您的App Delegate

在您的-applicationDidFinishLaunching:withOptions:附近,添加[UserSwitchManager setAPIKey:@"YOUR_API_KEY" apiSecret:@"YOUR_API_SECRET"],其中YOUR_API_KEYYOUR_API_SECRET是在您的仪表板的API文档中找到的两个特殊令牌。

Objective C
#import <UserSwitch/UserSwitch.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Add this line
    [UserSwitchManager setAPIKey:@"YOUR_API_KEY" apiSecret:@"YOUR_API_SECRET"];
    ...
}
Swift
import UserSwitch

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
{
    // Add this line
    UserSwitchManager.setAPIKey("YOUR_API_KEY", apiSecret:"YOUR_API_SECRET")
    ...
}

步骤 3

设置用户凭据

通常,当用户登录您的应用程序时,应设置用户的emailuserName,并在他们注销时调用-logOut

Objective C
#import <UserSwitch/UserSwitch.h>
{
   [UserSwitchManager setUserEmail:@"USER_EMAIL"];
   [UserSwitchManager setUserName:@"USER_NAME"];
    ...
}
Swift
import UserSwitch
{
    UserSwitchManager. setUserEmail("USER_EMAIL")
    UserSwitchManager. setUserName("USER_NAME")
    ...
}

步骤 4

报告用户

在您的-applicationDidBecomeActive:附近,调用-activateApp

Objective C
#import <UserSwitch/UserSwitch.h>

- (void)applicationDidBecomeActive:(UIApplication *)application 
{
    // Add this line
    [UserSwitchManager reportUserWithIdentifier:"USER_ID"];
    ...
}
Swift
import UserSwitch

func applicationDidBecomeActive(_ application: UIApplication) 
{
    // Add this line
    UserSwitchManager.reportUserWithIdentifier("USER_ID")
    ...
}

作者

Adam Cooper, [email protected]

许可证

UserSwitch 可在Apache 2.0 许可证下使用。查看LICENSE文件获取更多信息。