WEB开发网
开发学院手机开发iPhone 开发 为 iPhone 应用搭建 php 版 push 服务器的流程 阅读

为 iPhone 应用搭建 php 版 push 服务器的流程

 2010-08-26 11:20:00 来源:WEB开发网   
核心提示:13.新建一个View-based Application项目,在$PROJECT_NAMEAppDelegate.m中:a.粘贴如下代码:1. - (void)applicationDidFinishLaunching:(UIApplication *)app {2. // other setup tasks her

13.新建一个View-based Application项目,在$PROJECT_NAMEAppDelegate.m中:

a.粘贴如下代码:

1. - (void)applicationDidFinishLaunching:(UIApplication *)app {

2. // other setup tasks here….

3. [window addSubview:viewController.view];

4. [self alertNotice:@"" withMSG:@"Initiating Remote Noticationss Are Active" cancleButtonTitle:@"Ok" otherButtonTitle:@""];

5. [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound)];

6. }

7. - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

8. //NSLog(@"devToken=%@",deviceToken);

9. [self alertNotice:@"" withMSG:[NSString stringWithFormat:@"devToken=%@",deviceToken] cancleButtonTitle:@"Ok" otherButtonTitle:@""];

10. }

11. - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {

12. NSLog(@"Error in registration. Error: %@", err);

13. [self alertNotice:@"" withMSG:[NSString stringWithFormat:@"Error in registration. Error: %@", err] cancleButtonTitle:@"Ok" otherButtonTitle:@""];

14. }

15. -(void)alertNotice:(NSString *)title withMSG:(NSString *)msg cancleButtonTitle:(NSString *)cancleTitle otherButtonTitle:(NSString *)otherTitle{

16. UIAlertView *alert;

17. if([otherTitle isEqualToString:@""])

18. alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:cancleTitle otherButtonTitles:nil,nil];

19. else

20. alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:cancleTitle otherButtonTitles:otherTitle,nil];

21. [alert show];

22. [alert release];

Tags:iPhone 应用 搭建

编辑录入:coldstar [复制链接] [打 印]
赞助商链接