[英]How to enable and disable Parse push notifications Android
我有一個與Parse服務集成在一起的Android應用程序,能夠接收推送通知,但一切正常,但是我想添加一個開關,使用戶可以在其設備上啟用或禁用接收推送通知,但是我無法找到正確的方法。 任何幫助將非常感激。 謝謝。
實現此目的的最佳方法是為每個應用安裝添加一個布爾字段,讓您的ParseInstallation對象說“啟用”。 每次打開/關閉更新開關時,都可以為用戶更新ParseInstallation。 只需確保在推送任何通知之前檢查“啟用”字段即可。
ParseInstallation currentInst = ParseInstallation.getCurrentInstallation();
currentInst.put("enable", "<true/false>");
currentInst.saveInBackground();
現在,在推送通知之前,請像這樣查詢安裝
ParsePush parsePush = new ParsePush();
ParseQuery<ParseInstallation> installationParseQuery = ParseQuery.getQuery(ParseInstallation.class);
installationParseQuery.whereEqualTo("enable", true);
parsePush.sendInBackground();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.