iPhone 应用程序中的推送通知

发布于 2024-08-27 11:58:00 字数 71 浏览 4 评论 0原文

我需要在我的应用程序中实现推送通知。 实际上我必须从服务器接收消息。 请指导我如何在我的 iPhone 应用程序中实现推送通知。

I need to implement push notification in my application.
Actually i have to receive messages from the server.
Kindly guide me how i can implement push notifications in my iphone application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱人如己 2024-09-03 11:58:00

客户端的东西很简单,但如果您想要一个好的示例,我们提供了一个您可以下载的http://bitbucket .org/urbanairship/push_sample/

你会发现服务器端的东西要困难得多,为此我建议使用 Urban Airship,因为我们提供了一个简单的 RESTful 服务,你可以与很多附加组件一起使用功能和独立包是免费的。

http://urbanairship.com/docs/push_index.html

警告:我在那里工作。

The client side stuff is easy, but if you want a good example we provide one that you can download http://bitbucket.org/urbanairship/push_sample/

You'll find the server side stuff to be a lot more difficult and for that I would recommend using Urban Airship because we provide a simple RESTful service you can use with lots of add-on features and the indie package is free.

http://urbanairship.com/docs/push_index.html

caveat: I work there.

乱了心跳 2024-09-03 11:58:00

你需要在你的应用程序中实现这两个委托方法

- (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);

}

you need to implement these 2 delegate method in your application

- (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);

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文