아파치 코드 바를 기반으로 한 Android 앱이 있습니다. 이 애플리케이션에 대한 푸시 알림을 원합니다. Visual Studio 2015 IDE를 사용하여이 응용 프로그램을 작성했습니다. 나는 cordova-plugin-device-orientation, statusbar 등과 같은 애플리케이션 용 플러그인을 이미 설치했다.이 애플리케이션에 푸시 알림을 사용하려면 phonegap-plugin-push (버전 2.1.0)를 설치하고 보낸 사람 ID를 my Firebase를 사용하여 만든 응용 프로그램입니다. 새 프로젝트를 만들고 안드로이드 앱을 추가하고 google-services.json 파일을 다운로드하여 프로젝트에 배치했습니다. phonegap-plugin-push를 사용하여 apache cordova android app에 대한 플러그인 공지 푸시
<script>
function setupPush() {
//This line below throws error on simulator saying PushNotification //is not defined
var push = PushNotification.init({
"android": {
"senderID": "XXXXXXXXXX"
},
"ios": {
"sound": true,
"alert": true,
"badge": true
},
"windows": {}
});
alert('registered');
push.on('registration', function (data) {
alert('registration event' + data.registrationId);
console.log("registration event: " + data.registrationId);
var oldRegId = localStorage.getItem('registrationId');
if (oldRegId !== data.registrationId) {
// Save new registration ID
alert('registration event' + data.registrationId)
localStorage.setItem('registrationId', data.registrationId);
// Post registrationId to your app server as the value has changed
}
});
push.on('error', function (e) {
console.log("push error = " + e.message);
});
}
$(document).on('deviceready', function deviceIsReady() {
console.log('Device is ready!');
setupPush();
});
</script>
cordova-cli : 6.1.1, "android": "5.1.1" 안드로이드 플랫폼이 이미 설치되어 있으므로 내 안드로이드 앱이 이미 플레이 스토어에 배포되어 있으므로 지금은 변경할 수 없습니다. 안드로이드 앱을위한 푸시 알림 서비스를 추가하고 싶습니다. – Warda
@Warda 플러그인 버전이 5.1.1을 지원하지 않습니다. 6.2.1 이상을 사용해야합니다. https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/에서 참조하십시오. INSTALLATION.md –
visual studio 2015에서 apache cordova android app 프로젝트를 만들었습니까? – Warda