推送通知和查看按钮操作[iphone sdk APNS]

发布于 2024-10-05 16:43:52 字数 304 浏览 1 评论 0原文

我正在为 Iphone 开发一个启用推送通知的应用程序。 在我的应用程序中,我有两个列表视图(UITableView) 第一个是类别列表,第二个是内容列表。 用户单击所需的类别,然后将显示与该类别相关的内容,然后用户选择内容,内容将显示在详细视图(通常是 UIWebView)中。

推送通知已成功进入我的应用程序。 我的要求是:- 单击推送警报的 VIEW 按钮后,应用程序将直接显示特定的 详细视图(UIWebView)[省略类别和内容列表]。 我有一个类别和内容的唯一 ID。 那么,请您指导我如何将特定内容与推送通知相关联并直接显示该内容。

谢谢和问候。

I am developing a Push Notification enabled application for Iphone.
In My application I have two List View (UITableView)
1st for Category List and the 2nd is Contents List.
User clicks the desired category then the contents related to that category will be displayed then user will choose the contents and the contents will be displayed in detail view(generally a UIWebView).

Push notification is successfully coming in my application.
My requirement is:-
After VIEW button of Push alert is clicked application will directly display a particular
detail view (UIWebView)[Omitting category and contents list].
I have a unique ID for category and contents.
So will you please guide me how to relate a particular content with Push Notification and directly display of that content.

Thanks and regards.

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

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

发布评论

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

评论(1

泡沫很甜 2024-10-12 16:43:52

嗨,

我已经解决了这个问题。
这就是我所做的。
当应用程序收到推送通知时,它将通知存储在 launchOptions NSDictionary 中。

/* Push notification received when app is not running */
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
NSString *params=[[launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"] objectForKey:@"contTag"];

if ([params length] > 0 ) {//app launch when VIEW button of push notification clicked

 //do some processing   
 ........ 
 WebViewController *webViewController = 
    [[WebViewController alloc] initWithNibName:@"WebView" bundle:[NSBundle    mainBundle]];
    // Put your custom code


    [[self navigationController ] pushViewController:webViewController animated:YES];
    [window addSubview:navigationController.view];


/* Remote Notification Received while application was open. */


- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

NSLog(@"remote notification: %@",[userInfo description]);

NSString *contentsInfo = [userInfo objectForKey:@"contTag"];
NSLog(@"Received contents info : %@", contentsInfo);

NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];

NSString *alert = [apsInfo objectForKey:@"alert"];
NSLog(@"Received Push Alert: %@", alert);

NSString *sound = [apsInfo objectForKey:@"sound"];
NSLog(@"Received Push Sound: %@", sound);
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);


//-----------------------APNS HANDLE----------------
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive){
    NSLog(@" It is in active state");
    application.applicationIconBadgeNumber = [[apsInfo objectForKey:@"badge"] integerValue];
}
   else {

if ([contentsInfo length] > 0 ) {
      // Do whatever u want for push notification handle
}

笔记:
这里的 contTag 是在服务器端设置的用于推送通知的有效负载的密钥。
您可以在服务器端设置任何密钥。

希望它能帮助一些身体。
谢谢

HI,

I have solved the problem.
This is what I have done.
When application received push notification, it stored notification in launchOptions NSDictionary.

/* Push notification received when app is not running */
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
NSString *params=[[launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"] objectForKey:@"contTag"];

if ([params length] > 0 ) {//app launch when VIEW button of push notification clicked

 //do some processing   
 ........ 
 WebViewController *webViewController = 
    [[WebViewController alloc] initWithNibName:@"WebView" bundle:[NSBundle    mainBundle]];
    // Put your custom code


    [[self navigationController ] pushViewController:webViewController animated:YES];
    [window addSubview:navigationController.view];


/* Remote Notification Received while application was open. */


- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

NSLog(@"remote notification: %@",[userInfo description]);

NSString *contentsInfo = [userInfo objectForKey:@"contTag"];
NSLog(@"Received contents info : %@", contentsInfo);

NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];

NSString *alert = [apsInfo objectForKey:@"alert"];
NSLog(@"Received Push Alert: %@", alert);

NSString *sound = [apsInfo objectForKey:@"sound"];
NSLog(@"Received Push Sound: %@", sound);
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);


//-----------------------APNS HANDLE----------------
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive){
    NSLog(@" It is in active state");
    application.applicationIconBadgeNumber = [[apsInfo objectForKey:@"badge"] integerValue];
}
   else {

if ([contentsInfo length] > 0 ) {
      // Do whatever u want for push notification handle
}

NOTE:
Here contTag is a key set in server side for pay load of push notification.
U can set any key in server side.

Hope it will help some body.
Thanks

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