2017-10-12 3 views
1

webviewでアンドロイドアプリケーションを使用していて、固有のデバイスIDをPHPファイルに送信したいとします。 webview URLにandroid_id(またはデバイスID、アプリID)を追加するにはどうすればよいですか?このようなAndroid ID in webview url

何か:私は私のAndroidアプリコルドバ+ WebViewの+ Onesignalに使用

webview launchUrl = "https://www.exampledomain.com/myphp.php?androidid=ANDROID_ID"; 

ANDROID_ID= xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 
+0

あなたの質問はあいまいです。あなたはphpファイルまたはjavaファイルにAndroid IDを追加しますか?アンドロイドIDとは何ですか? XMLからの属性ID、またはデバイスからのIPの値または何か? PHPの場合、アンドロイドIDはグローバル$ _GET ['andoidid'] = $ value; – user8455694

+0

ANDROID_ID = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx webview launchUrl = "https://www.exampledomain.com/myphp.php?androidid="+ANDROID_ID; launchutとANDROID_IDを連結する – Sanil

+0

すべてのデバイスIDに基づいて別個の通知を送信するために、すべてのデバイスにPHPで登録する必要があるため、webviewでGET経由で送信するデバイスID(UUID)が必要です。たとえば、請求書通知、サービスが無効になったなど.Simpleは、私はそれらをターゲットにして通知を送信するために各デバイスのIDは何かをPHPで知る必要があります。 –

答えて

0

。私は今このコードを持っています:

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