Quantcast
Viewing all articles
Browse latest Browse all 8068

How to get the device token on iOS 7

I'm making the push notification on iOS 7, iPod gen 5. When I try to get the device token and I got the problem is: device token is undefined. here my code: function getDeviceToken() { if (isAndroid) { var CloudPush = require('ti.cloudpush'); CloudPush.retrieveDeviceToken({ success: function deviceTokenSuccess(e) { deviceToken = e.deviceToken; alert(deviceToken); subscribeToChannel(); }, error: function deviceTokenError(e) { alert('Failed to register for push! ' + e.error); } }); CloudPush.debug = true; CloudPush.enabled = true; CloudPush.showTrayNotificationsWhenFocused = true; CloudPush.focusAppOnPush = false; } else if (isIOS) { Titanium.Network.registerForPushNotifications({ // Specifies which notifications to receive types: [ Ti.Network.NOTIFICATION_TYPE_BADGE, Ti.Network.NOTIFICATION_TYPE_ALERT, Ti.Network.NOTIFICATION_TYPE_SOUND ], success: function(e) { alert(JSON.stringify(e)); deviceToken = e.deviceToken; subscribeToChannel(); alert("deviceToken = " + deviceToken); }, error: function(e) { alert("573 Error: " + e.message); }, callback: function(e) { alert("push notification received" + JSON.stringify(e.data)); } }); deviceToken = Titanium.Network.remoteDeviceUUID; alert('line 588' + deviceToken); } }

Viewing all articles
Browse latest Browse all 8068

Trending Articles