我已经设置了推送通知插件并调用了register方法,但它只返回一个字符串"OK"而不是设备ID.我如何获得注册的设备ID?
$window.plugins.pushNotification.register( function (result) { q.resolve(result); //this always just returns the string "OK", how do I get the device ID? }, function (error) { console.log(error); q.reject(error); }, config); return q.promise; },
e.regid为null,取自此示例
// Android and Amazon Fire OS function onNotification(e) { $("#app-status-ul").append('
MonkeyBonkey.. 5
所以我只是误解了推送库中的回调.iOS上的寄存器函数回调返回一个字符串标记,在Android中它只返回一个成功处理程序.Android版本中的注册事件的令牌ID必须在推送通知ecb处理程序而不是注册回调中处理.
所以在他们的例子中
if ( device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos" ){ pushNotification.register( successHandler, errorHandler, { "senderID":"replace_with_sender_id", "ecb":"onNotification" }); }
该函数在config属性"ecb"中设置为"onNotification"而不是在sucess处理程序中.
在这种情况下,您可以在原始问题中使用onNotification示例.我的错误是将onNotification函数作为Android中的成功处理程序传递,但实际情况并非如此.
所以我只是误解了推送库中的回调.iOS上的寄存器函数回调返回一个字符串标记,在Android中它只返回一个成功处理程序.Android版本中的注册事件的令牌ID必须在推送通知ecb处理程序而不是注册回调中处理.
所以在他们的例子中
if ( device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos" ){ pushNotification.register( successHandler, errorHandler, { "senderID":"replace_with_sender_id", "ecb":"onNotification" }); }
该函数在config属性"ecb"中设置为"onNotification"而不是在sucess处理程序中.
在这种情况下,您可以在原始问题中使用onNotification示例.我的错误是将onNotification函数作为Android中的成功处理程序传递,但实际情况并非如此.