phonegap-push-plugin 在 iOS 中不起作用

phonegap-push-plugin doesn't work in iOS

我的项目有问题。

我有一个 Ionic 项目,我正在使用 phonegap-plugin-push 发送推送通知。 在 Android 上运行良好,但在 iOS 上不起作用。不出现询问我是否要接收通知的警报并且未执行注册事件。

怎么了?

提前致谢。

这是我的代码:

document.addEventListener('deviceready', function() {
    console.log('>>>>>> DEVICE READY <<<<<<');
    handleNotificationReady();
});

function handleNotificationReady(){
    console.log('>>>> HandleNotificationReady <<<<');
    var pushNotification;

    if (device.platform == 'Android') {
        console.log('>>> Android, nice to meet you!');
        pushNotification = PushNotification.init({
            android: {
                senderID: '6610***',
                icon: 'icon'
            }
        });
    } else if (device.platform == 'iOS') {
        console.log('>>> iOS, nice to meet you!');
        pushNotification = PushNotification.init({
            ios: {
                alert: 'true',
                badge: 'true',
                sound: 'true'
            }
        });
    }

    pushNotification.on('registration', function(data) {
        console.log('>>>> REGISTRATION <<<<');
        console.log(data.registrationId);
    });

    pushNotification.on('notification', function(data) {
        console.log('>>>> NOTIFICATION <<<<');
        console.log(data);
    });

    pushNotification.on('error', function(err) {
        console.log('>>>> ERROR <<<<');
        console.log(err);
    });
}

这是我的控制台:

`>>>>>> DEVICE READY <<<<<<
>>>> HandleNotificationReady <<<<
>>> iOS, nice to meet you!`

我理解你的问题。

您是否尝试删除 push-plugin 并重新添加。然后删除并添加 iOS 平台,再次构建应用程序。

请尝试一下,如果它适合你,请告诉我。