Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为Google Analytics iOS实现用户ID_Ios_Objective C_Google Analytics - Fatal编程技术网

为Google Analytics iOS实现用户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,并且仍然能够在没有登录/注册

我将在我的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,但这可能会有所帮助: