我使用pushwoosh發送推送通知給我的應用程序,我想添加一些功能來檢查,如果用戶在他們的設備上關閉「Revicieve Notification」,我從pushwoosh發送的推送通知將不會觸發或提醒到那些設備。如何使應用程序關閉pushwoosh的通知?
PS。我使用科爾多瓦。
謝謝。
我使用pushwoosh發送推送通知給我的應用程序,我想添加一些功能來檢查,如果用戶在他們的設備上關閉「Revicieve Notification」,我從pushwoosh發送的推送通知將不會觸發或提醒到那些設備。如何使應用程序關閉pushwoosh的通知?
PS。我使用科爾多瓦。
謝謝。
對於科爾多瓦採取一看:在Pushwoosh插件getRemoteNotificationStatus功能:
的iOS。
在那裏檢查「啓用」鍵。
Android:除非您調用「unregisterDevice」函數,否則您可能會考慮用戶註冊。由於Android沒有檢查推送註冊狀態的API。你可以在這裏投了此功能:https://code.google.com/p/android/issues/detail?id=38482
我剛剛經歷了這個分鐘前,這個解決:
pushNotification.unregisterDevice(
function (token) {
console.log("unregisterDevice, token: " + token);
//alert("unregisterDevice, token: " + token);
},
function (status) {
console.warn("registerDevice failed, status:" + status);
//alert("registerDevice failed, status:" + status);
}
);
我們使用localStorage的保存設置,所以在我們的例子:
var storage = window.localStorage;
if (storage.getItem('pushNotification') == 'true') {
console.log('Pusnotifications ON');
//register for push notifications
pushNotification.registerDevice(
function (token) {
console.log('registerDevice, token: ' + token);
//alert('registerDevice, token: ' + token);
//callback when pushwoosh is ready
onPushwooshAndroidInitialized(token);
},
function (status) {
//alert("registerDevice failed to register, status: " + status);
console.warn(JSON.stringify(["registerDevice failed to register, status: ", status]));
}
);
} else if (storage.getItem('pushNotification') == 'false') {
console.log('Pusnotifications OFF');
//unregister for push notifications
pushNotification.unregisterDevice(
function (token) {
console.log("unregisterDevice, token: " + token);
//alert("unregisterDevice, token: " + token);
},
function (status) {
console.warn("registerDevice failed, status:" + status);
//alert("registerDevice failed, status:" + status);
}
);
}
正如你可能剛剛發現的那樣,這個'PushwooshAndroid.js'。我還沒有在iOS中完成這項工作,但期望它是一樣的。
希望這可以幫助你! FG
平臺?你的意思是說,如果用戶想要關閉通知,用戶可以從你的應用中選擇?或者你的意思是如果用戶關閉設置上的通知在iOS上? – jcesarmobile 2014-11-22 12:15:54
在iOS和Android上,我的意思是如果用戶選擇關閉我的應用程序的通知。當我發送pushwoosh的推送通知時,它不會發出警報。 – Giffary 2014-11-22 14:19:27