2013-08-07 108 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; 
} 

但是请注意更改此代码的任何不必要的副作用。可能有其他功能取决于此方法(现在和未来)。


见相关职位如何解析接收推送消息一个很好的解释:

相关问题