내 앱에서 푸시 알림을 구현할 수 있도록 cordovaPushV5 플러그인을 사용하고 있습니다.
나는이 튜토리얼에서 정확히 뭐하는 거지 : 내 브라우저에서 응용 프로그램을 실행하면 https://github.com/yafraorg/yafra/wiki/Blog-Ionic-PushV5
, 나는 콘솔에서 위의 오류가 발생합니다.
아래 그림과 같이 플러그인을 올바르게 설치하고 필요한 코드 줄을 내 App.js 파일에 포함 시켰습니다.
누군가 내가 잘못 가고 있는지 알 수 있습니까?
/****ENABLE RECEIVING OF PUSH NOTIFICATIONS****/
/*
* start within Platform ready
*/
$ionicPlatform.ready(function() {
// register push notification and get local push token
localStorage.myPush = ''; // I use a localStorage variable to persist the token
$cordovaPushV5.initialize( // important to initialize with the multidevice structure !!
{
android: {
senderID: "704649974960"
},
ios: {
alert: 'true',
badge: true,
sound: 'false',
clearBadge: true
},
windows: {}
}
).then(function (result) {
$cordovaPushV5.onNotification();
$cordovaPushV5.onError();
$cordovaPushV5.register().then(function (resultreg) {
localStorage.myPush = resultreg;
// SEND THE TOKEN TO THE SERVER, best associated with your device id and user
}, function (err) {
// handle error
});
});
});
/*
* Push notification events
*/
$rootScope.$on('$cordovaPushV5:notificationReceived', function(event, data) { // use two variables here, event and data !!!
if (data.additionalData.foreground === false) {
// do something if the app is in foreground while receiving to push - handle in app push handling
} else {
// handle push messages while app is in background or not started
}
if (Device.isOniOS()) {
if (data.additionalData.badge) {
$cordovaPushV5.setBadgeNumber(NewNumber).then(function (result) {
// OK
}, function (err) {
// handle error
});
}
}
$cordovaPushV5.finish().then(function (result) {
// OK finished - works only with the dev-next version of pushV5.js in ngCordova as of February 8, 2016
}, function (err) {
// handle error
});
});
$rootScope.$on('$cordovaPushV5:errorOccurred', function(event, error) {
// handle error
});
/****END ENABLE RECEIVING OF PUSH NOTIFICATIONS****/
'$ cordovaPushV5'를 컨트롤러에 삽입 했습니까? ngCordova.plugins.push_v5 모듈을 앱에 종속성으로 추가 했습니까? –
@RaviTeja 나는 주입 그 방과 코드는 내부에 : '.RUN (기능 ($ rootScope, $ cordovaPushV5, $ ionicPlatform, $ 상태, AuthService, AUTH_EVENTS) { // 코드를 여기에 }' 내가 추가하지 않은 그 종속성은 ngCordova를 설치 한 것입니다. 어떻게 추가합니까? –