[英]Unique identifier of Google Play Market / appstore user
有沒有辦法確定android / ios應用程序用戶的身份而無需請求他使用google / email / facebook注冊?
我想實現此目的:用戶從PlayMarket / AppStore下載應用程序,應用程序以某種方式識別他的身份,並將有關此用戶的數據發送到服務器。 “有關此用戶的數據”是指僅基於用戶在應用中的操作收集的數據,例如雜項首選項和設置。 如果用戶要卸載該應用程序,然后使用相同的Google帳戶再次將其安裝到其他設備上,則應正確識別出他是以前使用該應用程序的用戶。
在android中,您可以收集電子郵件地址,而無需詢問用戶是否在設備中登錄了google帳戶:
Account account = getAccount(AccountManager.get(getApplicationContext()));
if (account == null) {
String accountName = "user did not provide email";
} else {
String accountName = account.name;
}
public static Account getAccount(AccountManager accountManager) {
Account[] accounts = accountManager.getAccountsByType("com.google");
Account account;
if (accounts.length > 0) {
account = accounts[0];
} else {
account = null;
}
return account;
}
另一種方法是,您可以獲取設備ID。 但是,如果用戶更換設備並且未登錄google帳戶,它將無法滿足您的需求。 要獲取設備ID:
import android.provider.Settings.Secure;
String deviceId = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_ID);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.