我使用的解析做推送通知和我遇到的問題是,我的應用程序運行時(無論是在前臺或後臺)的手機的操作系統不顯示在通知欄推送通知。我需要做什麼更改才能看到通知欄上的推送顯示?如何在應用程序運行時在通知欄中顯示分析推送通知?
我的擴展應用類具有的onCreate()
// initialize Parse SDK
Parse.initialize(this, Constants.APPLICATION_ID_DEBUG, Constants.CLIENT_KEY_DEBUG);
ParsePush.subscribeInBackground(Constants.CHANNEL, new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Logger.i(TAG, "successfully subscribed to broadcast channel");
} else {
Logger.e(TAG, "failed to subscribe for push: " + e);
}
}
});
ParseInstallation.getCurrentInstallation().saveInBackground();
下面我在系統中了個手勢,我的應用程序,所以我用的ID登錄的用戶的頻道訂閱用戶。因此,在我的應用程序的第一個Activity中,我調用了onCreate()中的以下代碼片段。
private void registerNotifications() {
List<String> arryChannel = new ArrayList<String>();
arryChannel.add(session.id);
ParseInstallation parseInstallation = ParseInstallation.getCurrentInstallation();
parseInstallation.put("channels", arryChannel);
parseInstallation.saveEventually();
}
我也有一個自定義接收器正在工作。每次發送一個推送時,都會通過onPushReceive方法接收,但是,我希望推送顯示在通知欄中。
public class ParsePushReceiver extends ParsePushBroadcastReceiver {
private static final String TAG = ParsePushReceiver.class.getSimpleName();
@Override
public void onPushOpen(Context context, Intent intent) {
Log.i(TAG, "onPushOpen");
}
@Override
protected void onPushReceive(Context context, Intent intent) {
Log.i(TAG, "onPushReceive");
}
}
在此先感謝!
我很好奇,是不是標準的實施採取收到推送通知,然後以編程方式建立的通知,並推動它?我原以爲這將由操作系統來處理。 – portfoliobuilder
儘管如此,謝謝! – portfoliobuilder
唯一的問題是,點擊推送通知沒有任何操作。它不會調用onPushOpen()。我相信我需要採用相同的概念,除了使用Parse發送推送通知外。 – portfoliobuilder