简体   繁体   English

使用fcm插件的离子推送通知和徽章

[英]Ionic push notification and badge using fcm plugin

Good day everybody, 大家好,

I'm so newbie with ionic and apps and I'm trying integrate a badge icon in ios with this framework but I can't how do it. 我是离子和应用程序的新手,我正在尝试将ios中的徽章图标与此框架集成,但我不知道如何做到这一点。

In app.js I have push notification integrate, and I want when a push notification is received, the badge icon is counting the number notification. 在app.js我有推送通知集成,我想在收到推送通知时,徽章图标正在计算数字通知。

I'm using a plugin for push notification called "cordova plugin fcm". 我正在使用一个名为“cordova plugin fcm”的推送通知插件。 Can this plugin add this badge? 这个插件可以添加此徽章吗? Have I use other plugin? 我有其他插件吗? How can I integrate it? 我该如何整合它?

Thanks a lot for all. 非常感谢所有人。

I think this plugin can get you in action: https://github.com/katzer/cordova-plugin-badge 我认为这个插件可以让你发挥作用: https//github.com/katzer/cordova-plugin-badge

you just need to integrate this with the fcm plugin and you're good to go. 你只需要将它与fcm插件集成,你就可以了。 Thanks. 谢谢。

Thanks for the fast reply. 谢谢你的快速回复。 I write the following code, but I don't know if its correct or not (I'm really so newbie) 我写下面的代码,但我不知道它是否正确(我真的是这么新手)

        FCMPlugin.onNotification(
            function(data) {
                APPService.forceToDownloadAgain();
                Notificaciones.addNotification(data);
                console.log(data);
                if (data.wasTapped) {
                    //Received in device tray. Tapped by user
                    $state.go('global.notifies');
                    cordova.plugins.notification.badge.increase();
                } else {
                    //Received in foreground. Advice to user
                    $ionicPopup.confirm({
                        title: 'Notificación recibida',
                        template: 'Te gustaría ver la notificación que has recibido?'
                    }).then(function(res) {
                        if (res) {
                            $state.go('global.notifies');
                            cordova.plugins.notification.badge.clear();
                        }
                    });

                }

            },
            function(msg) {
                //OK
            },
            function(err) {
                //ERROR
            }
        );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM