【发布时间】:2016-09-08 23:50:39
【问题描述】:
我正在使用 Ionic 2。
我在尝试设置推送通知时收到此 Typescrpt 错误。我已经从教程中复制了这个示例代码,所以希望它能够工作。我一定有什么问题。任何想法请:
Unhandled Promise rejection: push.on is not a function ; Zone: angular ; Task: Promise.then ; Value: TypeError: push.on is not a function push.on('registration', function (data) {
打字稿
import { Push } from 'ionic-native';
。 .
pushNotifications(): void {
var push = Push.init({
android: {
vibrate: true,
sound: true,
senderID: "xxxxxxxxxxxxxxxxxxx"
},
ios: {
alert: "true",
badge: true,
sound: 'false'
},
windows: {}
});
push.on('registration', (data) => {
console.log(data.registrationId);
alert(data.registrationId.toString());
});
push.on('notification', (data) => {
console.log(data);
alert("Hi, Am a push notification");
});
push.on('error', (e) => {
console.log(e.message);
});
}
【问题讨论】:
-
尝试了以下相同的错误:
push.on('registration', function (data) { console.log('++++++++++++++++++++++ FIRE ON!!'); alert(data); }); -
很高兴我不是唯一一个。您对此有任何解决方案吗?
-
还没有。与此同时,我已经开始着手其他工作了。
标签: javascript angular typescript ionic-framework ionic2