离子推送 - 未在设备上获取令牌

Ionic Push - not getting token on device

我似乎无法让 Ionic Push 工作,过去 3 天我一遍又一遍地完成了 "Push From Scratch" 和 IOS 设置教程。

我可以向设备发送开发推送 - 它们作为警报显示正常,但是当我切换为使用开发证书通过 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 调用可能是异步的,但这是日志中的最后一个条目。

我用的是xcode6.4,测试设备是iphone4s运行最新发布的iOS.

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