2013-11-20 51 views
0

我想通過使用Parse.I通過推送通知開始谷歌播放我通過使用Parse儀表板的JSON發送URL並獲取它。我用廣播接收機嘗試了很多,但無處可去。那麼一點點的幫助或提示將是明顯的使用Parse.com通過推送通知打開Play商店應用android

代碼

IntentFilter intentFilter = new IntentFilter("MyAction"); 

pushReceiver = new BroadcastReceiver() { 
    public void onReceive(Context context, Intent intent) { 
     Bundle extras = intent.getExtras(); 
     String message = extras != null ? extras.getString("com.parse.Data") : ""; 
     try { 
      JSONObject jsonObject = new JSONObject(message); 
      String url = jsonObject.getString("url"); 
      try { 
       startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + url)); 
      } catch (android.content.ActivityNotFoundException anfe) { 
       startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + url))); 
      }            
     } catch (JSONException e) { 
      e.printStackTrace(); 
     } 
    } 
}; 
registerReceiver(pushReceiver, intentFilter); 
+2

「我試了很多與廣播接收機」 - 你有什麼試過?發佈您的代碼,預期結果以及實際發生的事情。 –

+1

就像用戶沒有更新他的應用一樣,它就像app store store更新一樣。我想檢查一下,如果我自己也可以使用解析來做到這一點? @CommonsWare – MGDroid

+1

@Tanis.7x實際上是我用調試器試過的代碼工作正常。問題是,當我在沒有調試的情況下嘗試它時,它只是打開我在應用程序中設置的頁面。代碼從onstart()調用。 – MGDroid

回答

0

我從代碼中發現些什麼,如果你不通過重寫做任何魔法ParsePushBroadcastReceiveronPushOpen,你可以通過網頁添加一個uri和一個動作,從設置郵件的類型JSON。比如這一次,我們用它來向用戶發送有關可用更新的信息播放(如果有版本是非常過時):

{ 
    "title": "<the title goes here>", 
    "alert": "<the message goes here>", 
    "uri": "https://play.google.com/store/apps/details?id=<package name>", 
    "action": "android.intent.action.VIEW" 
} 

沒有必要的代碼,因爲ParsePushBroadcastReceiver是照顧的是(使用解析版本1.9.4)

+0

由於解析即將關閉,我想用這個,但它看起來不像它的工作。它只是開啓主要活動 – Sree

相關問題