Titanium JIRA Archive
Appcelerator Community (AC)

[AC-870] iOS 7 - registerForPushNotifications does not trigger success or error event

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNot Our Bug
Resolution Date2014-11-18T23:47:34.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labels3.4.0, 3.4.1, ios7, pushnotification
ReporterTim Varney
AssigneeRadamantis Torres-Lechuga
Created2014-11-18T17:22:18.000+0000
Updated2016-03-08T07:37:10.000+0000

Description

The following code does not result in a registration for push notification services on devices running iOS 7.1. if (Ti.Platform.name == "iPhone OS" && parseInt(Ti.Platform.version.split(".")[0]) >= 8) { // placeholder } else { // For iOS 7 and earlier Ti.Network.registerForPushNotifications({ // Specifies which notifications to receive types: [ Ti.Network.NOTIFICATION_TYPE_BADGE, Ti.Network.NOTIFICATION_TYPE_ALERT, Ti.Network.NOTIFICATION_TYPE_SOUND ], success: deviceTokenSuccess, error: deviceTokenError, callback: receivePush }); } // Process incoming push notifications function receivePush(e) { alert('Received push: ' + JSON.stringify(e)); } // Save the device token for subsequent API calls function deviceTokenSuccess(e) { deviceToken = e.deviceToken; alert('success'); } function deviceTokenError(e) { alert('Failed to register for push notifications! ' + e.error); }

Comments

  1. Tim Varney 2014-11-18

    Upon further inspection, this is not a problem with the titanium implementation of APN. It was a problem with my code. http://docs.appcelerator.com/titanium/3.0/#!/guide/Subscribing_to_push_notifications
  2. Tim Varney 2014-11-18

    FYI, the sample code on http://docs.appcelerator.com/titanium/3.0/#!/guide/Subscribing_to_push_notifications will not work for iOS 7. It is attempting to call the deviceTokenSuccess function before it is defined.

JSON Source