Tôi đang sử dụng Ionic 2.Unhandled Promise từ chối: push.on không phải là một chức năng
tôi có được điều này Typescrpt lỗi khi cố gắng thiết lập Notifications Push. Tôi đã sao chép mã mẫu này từ một hướng dẫn, vì vậy có thể dự kiến nó sẽ hoạt động. Tôi phải có một cái gì đó sai trái. Bất cứ ý tưởng hài lòng:
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) {
nguyên cảo
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);
});
}
thử những điều sau với lỗi tương tự: 'push.on ('đăng ký', function (data) { console.log ('++++++++++++++++ ++++++ FIRE ON !! '); cảnh báo (dữ liệu); });' – Richard
Vui vẻ không phải là người duy nhất. Bạn đã giải quyết vấn đề này chưa? –
Chưa. Tôi đã chuyển sang một số công việc khác trong thời gian đó trong khi tôi cố gắng tìm ra nó. – Richard