Ich verwende das folgende Plugin https://github.com/phonegap/phonegap-plugin-push mit meiner Phonegap-Anwendung. Ich bekomme auf der ioS-Version beim Registrierungsereignis nichts. Auf Android funktioniert es 100%. Ich bitte um Hilfe, um zu sehen, ob mir etwas fehlt. Der Code ist unten. Ich habe die Zertifikate und habe Push-Dienste aktiviert. Ich habe ein Verteilungszertifikat erstellt und die Anwendung befindet sich im Apple Store. Grundsätzlich habe ich beim Start eine Selbstanruffunktion und sende die Registrierung über http an unseren Server, wir bekommen nichts von ioS. Wir haben phonegapbuild verwendet, um die ioS-Version zu erstellen und über macincloud.com hochzuladen. Ich habe ein paar Posts hier gelesen, aber keiner löst mein Problem.PhoneGap Push-Plugin registriert nicht auf ioS
<gap:plugin name="phonegap-plugin-push" source="npm" >
<param name="SENDER_ID" value="15971xxxxxxx" />
</gap:plugin>
Meine Umgebung ist Windows-10 Cordova -v 6.0.0 phonegap -v 5.5.0 Push-Plugin -v 1.5.3
Und hier ist der Code
(function() {
'use strict';
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var samplePushApp = angular.module('samplePushApp');
samplePushApp.factory('deviceService', deviceService);
deviceService.$inject = ['$http', '$q', '$cordovaDevice', 'messagesSqlLiteService'];
function deviceService($http, $q, $cordovaDevice, messagesSqlLiteService) {
var url = 'http://example.com/api/device/';
console.log("PushNotification Registration");
var push = PushNotification.init({
"android": {"senderID": "15971xxxxxxx"},
"ios": {"alert": "true", "badge": "true", "sound": "true"},
"windows": {} });
push.on('registration', function(data) {
console.log(data.registrationId);
console.log("data.registrationId");
var model = $cordovaDevice.getModel();
var platform = $cordovaDevice.getPlatform();
var uuID = $cordovaDevice.getUUID();
var version = $cordovaDevice.getVersion();
var data = { "model": model, "platform": platform, "registrationId": data.registrationId, "DeviceId": uuID , "version ": version };
console.log(JSON.stringify(data));
$http.post(
url,
JSON.stringify(data),
{
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}
).success(function() {
console.log("Device Info submitted");
}).error(function(data, status) {
console.error('Device Info error', status, data);
});
});
push.on('notification', function(data) {
navigator.notification.alert(data.title+" Message: " + data.message, function(){}, "", "");
messagesSqlLiteService.insert(data);
location.href = '#messages';
});
push.on('error', function(e) {
console.log(e.message);
});
}
// create an injector
var $injector = angular.injector(['samplePushApp']);
$injector.invoke(deviceService);
}
})();
Gelöst
Als ein Update. Es stellt sich heraus, dass mit dem Code nichts falsch ist. Es gab zwei Hauptprobleme.
Ich lieh mir schließlich einen Mac (von macincloud) und baute das Projekt mit
phonegap build ios
der ersten Ausgabe: Ich habe diesen Fehler
Build Error
===========
ld: '/Users/user000516/Downloads/my-app - ioS/platforms/ios/samplePush/Plugins/phonegap-plugin-push/GCM/Libraries/libGGLCloudMessaging.a(GGLContext+CloudMessaging.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
, die den Push-Plug bedeutet konnte nicht mit Bitcode kompilieren aktiviert. Ich habe den Bitcode in xCode deaktiviert und das Projekt erfolgreich erstellt. Ich bin mir nicht sicher, ob dies der Grund war, warum der Build von Phonegap Build fehlgeschlagen ist.
Das zweite Problem: Die andere Sache, die ich von XCode tat, war, die Capabilities-Registerkarte zu bekommen und die Push-Notification-Funktion zu aktivieren.
Nach diesen Änderungen funktionierte der Code wie erwartet.
Hoffnung hilft dieses jemand
Hallo! Ich habe das gleiche Problem. Ich habe versucht, den Bitcode in meiner project.pbxproj Datei zu deaktivieren, funktioniert aber noch nicht. Hast du eine andere Lösung? Vielen Dank im Voraus – eliangela
Hi eliangela benutzt du auch das phonegap push Plugin. Welchen Fehler bekommst du? – alphacoder
Ja. Ich benutze Phonegap Push Plugin. Aber ich habe keinen Fehler :( Mein iPhone registriert nicht und gibt das Token nicht zurück – eliangela