2017-10-12 2 views
1

webview가있는 안드로이드 응용 프로그램이 있으며 고유 한 장치 ID를 PHP 파일로 보내려고합니다. webview url에 android_id (또는 device id, app id)를 어떻게 추가 할 수 있습니까? 이 같은안드로이드 ID in webview url

뭔가 : 내 안드로이드 응용 프로그램 코르도바 + 웹보기 + Onesignal 사용

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

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

귀하의 질문은 모호합니다, 당신은 PHP 파일이나 자바 파일에 안드로이드 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; 런치 URL과 ANDROID_ID를 연결합니다. – Sanil

+0

모든 장치 ID를 기반으로 고유 한 알림을 보내려면 모든 장치에 PHP로 등록해야하므로 webview에서 GET을 통해 장치 ID (UUID)를 보내야합니다. 예를 들면 : 송장 통지, 서비스 활성화 비활성화 등. 간단히 말해서 나는 그들을 타겟으로하고 통보를 보내는 각 장치의 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