며칠 전 phonegap push 플러그인을 사용하는 동안 GCM 토큰 대신 APNS 토큰을 얻는 데 문제 가 있었습니다 .
음, 설정을 변경하고 [ios] 블록에 senderID를 넣고 앱을 다시 컴파일했습니다. 이제 Iphone에서 regustrationId를 전혀 얻지 못합니다. Android에서는 여전히 잘 작동합니다. 누가 문제가 될 수 있는지 말해 줄 수 있습니까?
다음은 플러그인 설정입니다.
var push = PushNotification.init({
android: {
senderID: "8225....8910"
},
ios: {
senderID: "8225....8910",
alert: "true",
badge: "true",
sound: "false"
},
windows: {}
});
그리고이 이벤트는 절대 호출되지 않습니다.
push.on('registration', function(data) {
$.ajax({
url: '/authentication/ajax-register-gcm-token/',
data: {token: data.registrationId},
success: function (json) {
alert('Phone registered' + data.registrationId);
}
});
});
Push Notification Plugin Object 초기화에 사용한 코드가 잘못되었습니다. 다음과 같아야합니다.
var push = PushNotification.init({
android: {
senderID: "XXXXXXXXXXXX",
},
ios: {
alert: "true",
badge: "true",
sound: "true",
}
});
push.on('registration', function(data) {
console.log(data.registrationId);
registerDeviceToken(data.registrationId);
});
push.on('notification', function(data) {
console.log("notification event");
alert(JSON.stringify(data));
});
push.on('error', function(e) {
console.log("push error");
alert(JSON.stringify(e));
});
function registerDeviceToken(deviceToken){
//Register the registrationId or deviceToken to your server as per the webservice type and parameters configuration set
//From your code snippet above
$.ajax({
url: '/authentication/ajax-register-gcm-token/',
data: {token: deviceToken},
success: function (json) {
alert('Phone registered' + deviceToken);
}
});
}
공식 링크 에서도 여기에 언급 된 SenderID 가 없습니다 . 프로젝트의 기능 섹션에서 푸시 알림 서비스를 켰는 지 확인 하고 서버 측 코드 에 올바른 개발 및 프로덕션 APNS p12 파일과 해당 암호를 입력 했는지 확인하십시오 . 따라서 개발 프로필로 앱을 실행하는 경우 iOS 장치에서 수신하려면 푸시 알림을 보내는 개발 p12 파일 환경이 있어야합니다. 개발 및 프로덕션 APNS p12 인증서를 설정하려면 다음 링크를 참조하십시오. APNS 설정
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다