|
ObjectiveC
IntroductionTo send Push Notifications to a device, you need a device token. Device token is generated by Apple from Device ID and Application ID, so this is unique per device and per application. DeprecatedPlease, see the Objective-C Demo Project at http://code.google.com/p/apns-php/source/browse/trunk/Objective-C%20Demo Code/**
* @file
* Application delegate implementation.
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://code.google.com/p/apns-php/wiki/License
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to aldo.armiento@gmail.com so we can send you a copy immediately.
*
* @version $Id$
*/
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize window;
#pragma mark -
#pragma mark Application delegate
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window makeKeyAndVisible];
#if !TARGET_IPHONE_SIMULATOR
[application registerForRemoteNotificationTypes:
UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];
#endif
}
#pragma mark -
#pragma mark Remote notifications
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// You can send here, for example, an asynchronous HTTP request to your web-server to store this deviceToken remotely.
NSLog(@"Did register for remote notifications: %@", deviceToken);
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@"Fail to register for remote notifications: %@", error);
}
#pragma mark -
#pragma mark Memory management
/**
* Deallocates the memory occupied.
*/
- (void)dealloc {
[window release];
[super dealloc];
}
@endPlease, use ApnsPHP Google Group for help requests or to discuss about this project. To report an issue use Issues. Thanks! |