离子推 - 没有在设备上获得令牌

时间:2015-07-20 18:38:34

标签: ios cordova apple-push-notifications ionic-framework

我似乎无法让Ionic Push工作,最近3天我完成了#34; Push From Scratch"和IOS设置教程一遍又一遍。

我可以将dev推送到设备 - 它们显示为警报,但是当我切换到使用开发证书通过APN发送推送时出错了。使用日志我可以看到$ cordovaPush.register以某种方式失败,但奇怪的是它没有将任何错误(或成功消息)写入xcode控制台。 请参阅下面的代码:

if (app.dev_push) {...} else {
 console.log('before');
                $cordovaPush.register(config).then(function (token) {
                    console.log('$ionicPush:REGISTERED', token);

                    defer.resolve(token);

                    if (token !== 'OK') {

                        $rootScope.$emit('$cordovaPush:tokenReceived', {
                            token: token,
                            platform: 'ios'
                        });

                        // Push the token into the user data
                        try {
                            $ionicUser.push('_push.ios_tokens', token, true);
                        } catch (e) {
                            console.warn('Received push token before user was identified and will not be synced with ionic.io. Make sure to call $ionicUser.identify() before calling $ionicPush.register.');
                        }
                    }
                }, function (err) {
                    console.error('$ionicPush:REGISTER_ERROR', err);
                });
                console.log('after');

这是日志:

2015-07-20 20:13:23.530 PassionApp[4419:727003] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/686516FA-FA77-4D78-AE1B-08A245D0C06F/Library/Cookies/Cookies.binarycookies
2015-07-20 20:13:24.170 PassionApp[4419:727003] Apache Cordova native platform version 3.8.0 is starting.
2015-07-20 20:13:24.174 PassionApp[4419:727003] Multi-tasking -> Device: YES, App: YES
2015-07-20 20:13:24.200 PassionApp[4419:727003] Unlimited access to network resources
2015-07-20 20:13:24.618 PassionApp[4419:727003] [CDVTimer][keyboard] 0.677943ms
2015-07-20 20:13:24.619 PassionApp[4419:727003] Init FacebookConnect Session
2015-07-20 20:13:24.659 PassionApp[4419:727003] [CDVTimer][facebookconnectplugin] 39.842010ms
2015-07-20 20:13:24.660 PassionApp[4419:727003] [CDVTimer][TotalPluginStartup] 42.838991ms
2015-07-20 20:13:25.639 PassionApp[4419:727003] active
2015-07-20 20:13:25.734 PassionApp[4419:727003] Attempting to badge the application icon but haven't received permission from the user to badge the application
2015-07-20 20:13:26.277 PassionApp[4419:727003] Resetting plugins due to page load.
2015-07-20 20:13:27.918 PassionApp[4419:727003] Finished load of: file:///private/var/mobile/Containers/Bundle/Application/3BB4429C-2615-4136-A122-7496C351917C/PassionApp.app/www/index.html#/app/intro

2015-07-20 20:13:29.641 PassionApp[4419:727003] THREAD WARNING: ['Device'] took '15.608154' ms. Plugin should use a background thread.

2015-07-20 20:13:29.904 PassionApp[4419:727003] THREAD WARNING:
 ['PushPlugin'] took '33.658936' ms. Plugin should use a background thread.

2015-07-20 20:13:29.907 PassionApp[4419:727003] before

2015-07-20 20:13:29.908 PassionApp[4419:727003] after

我意识到apn调用可能是异步的,但这是日志中的最后一个条目。

我使用的是xcode 6.4,测试设备是运行最新发布的iOS的iphone 4s。

1 个答案:

答案 0 :(得分:0)

我修好了。 出于某种原因,Xcode项目没有使用正确的配置文件,我删除了所有内容并重新开始 - 这就是诀窍。

相关问题