我用我的Android應用科爾多瓦+網頁視圖+ Onesignal。我現在有這樣的代碼:
private static String uniqueID = UUID.randomUUID().toString();
private static final String PREFS_GT_PLAYER_ID = "GT_PLAYER_ID";
public synchronized static String id(Context context) {
if (uniqueID == null) {
SharedPreferences sharedPrefs = context.getSharedPreferences(PREFS_GT_PLAYER_ID, Context.MODE_PRIVATE);
uniqueID = sharedPrefs.getString(PREFS_GT_PLAYER_ID, null);
if (uniqueID == null) {
uniqueID = UUID.randomUUID().toString();
SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putString(PREFS_GT_PLAYER_ID, uniqueID);
editor.commit();
}
}
return uniqueID;
}
private void setStartUrl(String src) {
Pattern schemeRegex = Pattern.compile("^[a-z-]+://");
Matcher matcher = schemeRegex.matcher(src);
if (matcher.find()) {
launchUrl = src;
} else {
if (src.charAt(0) == '/') {
src = src.substring(1);
}
launchUrl = "https://www.exampledomain.com/myphp.php?androidid=" + uniqueID;
}
}
uniqueID是隨機生成的,但我想從onesignal生成player_id。 This is a print screen from my onesignal account
您的問題是ambigous,你想要添加Android ID到PHP文件或Java文件?什麼是Android ID?來自xml的屬性ID,還是來自設備的IP值或什麼?如果在PHP剛剛添加了全局$ _GET ['andoidid'] = $ value; – user8455694
ANDROID_ID = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx webview launchUrl =「https://www.exampledomain.com/myphp.php?androidid="+ANDROID_ID; 使用launchUrl concat ANDROID_ID – Sanil
我需要設備ID(UUID)通過在web視圖中發送becouse我需要在PHP中註冊每個設備以基於每個設備ID發送不同的通知。例如:發票通知,服務激活停用etc.Simply我需要知道在PHP是什麼是每個設備的目標他們的身份和發送通知。 –