Abd*_*mad 8 iphone objective-c push-notification
我需要在我的应用程序中实现推送通知.实际上我必须从服务器接收消息.请指导我如何在我的iphone应用程序中实现推送通知.
小智 7
客户端的东西很简单,但是如果你想要一个很好的例子我们提供一个你可以下载的东西http://bitbucket.org/urbanairship/push_sample/
你会发现服务器端的东西要困难得多,为此我建议使用Urban Airship,因为我们提供了一个简单的REST服务,你可以使用它有很多附加功能,独立包是免费的.
http://urbanairship.com/docs/push_index.html
警告:我在那里工作.
你需要在你的应用程序中实现这两个委托方法
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
//NSLog(@"Entered into Method");
NSString *myDevTokenString = [devToken description];
NSLog(myDevTokenString);
self.tokenAsString = [[devToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
NSLog(@"token As String:%@", tokenAsString);
//const void *devTokenBytes = [devToken bytes];
//NSLog(@"My Token is : %@",devToken);
//self.registered = YES;
// UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"APNClient-GotToken" message:myDevTokenString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
// [myAlert show];
// [myAlert release];
//[self sendProviderDeviceToken:devTokenBytes]; // custom method
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
//UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"APNClient" message:@"called -Error- Method" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
// [myAlert show];
// [myAlert release];
NSString *errText = [[NSString alloc] initWithFormat:@"APN Error:%@",err];
NSLog(@"Error in registration. Error: %@", errText);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13694 次 |
| 最近记录: |