2014-11-22 46 views
1

我使用pushwoosh发送推送通知给我的应用程序,我想添加一些功能来检查,如果用户在他们的设备上关闭“Revicieve Notification”,我从pushwoosh发送的推送通知将不会触发或提醒到那些设备。如何使应用程序关闭pushwoosh的通知?

PS。我使用科尔多瓦。

谢谢。

+0

平台?你的意思是说,如果用户想要关闭通知,用户可以从你的应用中选择?或者你的意思是如果用户关闭设置上的通知在iOS上? – jcesarmobile 2014-11-22 12:15:54

+0

在iOS和Android上,我的意思是如果用户选择关闭我的应用程序的通知。当我发送pushwoosh的推送通知时,它不会发出警报。 – Giffary 2014-11-22 14:19:27

回答

0

对于科尔多瓦采取一看:在Pushwoosh插件getRemoteNotificationStatus功能:
的iOS
在那里检查“启用”键。
Android:除非您调用“unregisterDevice”函数,否则您可能会考虑用户注册。由于Android没有检查推送注册状态的API。你可以在这里投了此功能:https://code.google.com/p/android/issues/detail?id=38482

2

我刚刚经历了这个分钟前,这个解决:

  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

相关问题