离子推送 - 未在设备上获取令牌
Posted
技术标签:
【中文标题】离子推送 - 未在设备上获取令牌【英文标题】:Ionic Push - not getting token on device 【发布时间】:2015-07-20 18:38:33 【问题描述】:我似乎无法让 Ionic Push 工作,过去 3 天我一遍又一遍地完成了“Push From Scratch”和 ios 设置教程。
我可以将开发推送发送到设备 - 它们显示为警报很好,但是当我切换到使用开发证书通过 APN 发送推送时出现问题。使用日志我可以看到 $cordovaPush.register 以某种方式失败,但奇怪的是它不会将任何错误(或成功消息)写入 xcode 控制台。 请参阅下面的 sn-p:
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】:我修好了。 由于某种原因,Xcode 项目没有使用正确的配置文件,我删除了所有内容并重新开始 - 成功了。
【讨论】:
以上是关于离子推送 - 未在设备上获取令牌的主要内容,如果未能解决你的问题,请参考以下文章