OneSignal推送打开网址,而不是打开应用程序

时间:2018-03-12 09:59:07

标签: ionic-framework push-notification onesignal

我创建了一个基于WordPress REST API(WP-JSON)的离子应用程序来显示离子版本1的内容。现在我想在WordPress管理面板上创建新帖子时集成OneSignal推送通知。我安装了OneSignal WordPress Plugin。现在我能够在Android手机上获得推送。但是当点击通知时,它会打开WordPress网站网址,而不是打开特定帖子的应用详情页面。

这是我的JS代码 -

angular.module('starter', ['ionic', 'starter.services', 'starter.controllers', 'starter.translate', 'ngStorage', 'ionic.closePopup', 'ab-base64', 'ngOpenFB', 'ngCordovaOauth','starter.directive'])
.run(function($ionicPlatform, $rootScope, $ionicLoading, $ionicPopup, $localStorage, $timeout, $http, $state, base64, ngFB) {
$ionicPlatform.ready(function() {
if(window.plugins){
            var notificationOpenedCallback = function(data){
                if(ionic.Platform.isAndroid()) var additionalData = JSON.parse(data.notification.payload.additionalData);
                else var additionalData = data.notification.payload.additionalData;
                if(angular.isDefined(additionalData)){
                    if(angular.isDefined(additionalData.posts)){
                        var posts = Number(additionalData.posts);
                        $state.go("app.news",{id:posts});
                    }
                    else if(angular.isDefined(additionalData.category)){
                        var category = Number(additionalData.category);
                        $state.go("app.category",{id:category});
                    }
                }
            };
            window.plugins.OneSignal
            .startInit(onesignal_app_id, onesignal_project_number)
            .handleNotificationOpened(notificationOpenedCallback)
            .inFocusDisplaying(window.plugins.OneSignal.OSInFocusDisplayOption.Notification)
            .endInit();
        }
});
})

请注意我确实错了,任何帮助都会受到赞赏。

0 个答案:

没有答案