2013-08-07 144 views

回答

0

這是設計並遵循常規UI約定。

幸運的是,插件是開源的,你可以改變行爲。


傳入的推送消息由GCMIntentService處理。

onMessage()方法檢查該應用是否在前臺與否:

if (PushPlugin.isInForeground()) { 
    extras.putBoolean("foreground", true); 
    PushPlugin.sendExtras(extras); 
} 
else { 
    extras.putBoolean("foreground", false); 

    // Send a notification if there is a message 
    if (extras.getString("message") != null && extras.getString("message").length() != 0) { 
     createNotification(context, extras); 
    } 
} 

修改if (PushPlugin.isInForeground()) {...}語句來完成你所需要的。


另一種方法是修改PushPlugin.isInForeground()本身的代碼。

public static boolean isInForeground() 
{ 
    return gForeground; 
} 

但是請注意更改此代碼的任何不必要的副作用。可能有其他功能取決於此方法(現在和未來)。


見相關職位如何解析接收推送消息一個很好的解釋:

相關問題