Reputation: 87161
I want to send a push-notification from the Python code (Django app) to client's phones.
I found several implementations, one of them is here: http://leepa.github.com/django-iphone-push/
My question is - how to identify the device for which I'm sending the notification to? Should I use the UDID of the phone? My concern is that it's already deprecated in iOS5, so I'm wondering how to tie the user with the phone in my Django server?
Upvotes: 1
Views: 4711
Reputation: 2644
From the docs:
Note: A device token is not the same thing as the device UDID returned by the uniqueIdentifier property of UIDevice.
Token used is acquired by registering for remote notifications in application:didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
// ...
}
If registering was successful, your app delegate will receive application:didRegisterForRemoteNotificationsWithDeviceToken:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *deviceTokenStr = [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
NSLog(@"%@", deviceTokenStr);
}
This is the token you use to send push notifications.
P.S.: django-iphone-push last commit was 3 years ago. You can try my fork called django-ios-push.
Upvotes: 1
Reputation: 41
Apple only let's you send notification to devices on which your iOS applicaiton is installed and for which the user has allowed your app to deliver notifications to their device. You can find more information on how Apple handles (push) notifications in this developer document.
If you don't have an iOS applications but still want to deliver notifications to users, you can consider to use Prowl, Notifio or Boxcar. These apps allow you to user their API to deliver the notifications to a users device. For most of these services their are Python packges available.
Upvotes: 2