为Google Analytics iOS实现用户ID
我将在我的iOS应用程序中使用Google Analytics,该应用程序没有任何登录/注册机制,这意味着我没有“应用程序生成的用户ID” 因此,当我实施新的Google Analytics(Universal Analytics)时,我想利用“用户跟踪”功能,它允许我们跨设备跟踪同一用户 是否可以从iOS中的SDK获取Apple Id,并将其设置为Google Analytics的用户Id?或者有没有其他方法可以让我在Google Analytics中设置用户id,并且仍然能够在没有登录/注册的情况下跨设备跟踪用户为Google Analytics iOS实现用户ID,ios,objective-c,google-analytics,Ios,Objective C,Google Analytics,我将在我的iOS应用程序中使用Google Analytics,该应用程序没有任何登录/注册机制,这意味着我没有“应用程序生成的用户ID” 因此,当我实施新的Google Analytics(Universal Analytics)时,我想利用“用户跟踪”功能,它允许我们跨设备跟踪同一用户 是否可以从iOS中的SDK获取Apple Id,并将其设置为Google Analytics的用户Id?或者有没有其他方法可以让我在Google Analytics中设置用户id,并且仍然能够在没有登录/注册
提前感谢。没有跨多个设备跟踪用户的直接方法。不过,通过创建唯一标识符并跨设备存储,您应该能够使用iCloud实现这一点。像这样的东西应该可以
+ (NSString *) getOrCreateIdentifier
{
static NSString *userIdentifier;
static NSString * const kUserIdentifierKey = @"kUserIdentifierKey";
if(! userIdentifier.length)
{
NSUbiquitousKeyValueStore *cloudStore = [NSUbiquitousKeyValueStore defaultStore];
userIdentifier = [cloudStore stringForKey:kUserIdentifierKey];
if(! userIdentifier.length)
{
userIdentifier = [[NSUUID UUID] UUIDString];
[cloudStore setString:userIdentifier forKey:kUserIdentifierKey];
}
}
return userIdentifier;
}
Apple不允许您直接获取Apple ID,但这可能会有所帮助: