Note that there are some explanatory texts on larger screens.

plurals
  1. POSet Action on Local Notification in iphone SDK
    primarykey
    data
    text
    <p>In my app, i scheduled Local Notification on my first view Controller. It works fine. To set the action on "View" button my code is as below:</p> <pre><code>//AppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if (localNotif) { // did something Here when app launch by View button of notification // added row in Db } return YES; } - (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif { // Handle the notificaton when the app is running NSLog(@"Recieved Notification %@",notif); app.applicationIconBadgeNumber=notif.applicationIconBadgeNumber++; } </code></pre> <p><strong>Question: It works fine for the first time only.</strong></p> <p><strong>But for the second time, the notification is showing but the row is not added in my DB</strong></p> <p><strong>// Edited</strong></p> <p>I want to give some action when user presses the button "View".</p> <p>How can I identify that action?</p> <p><strong>edited</strong></p> <pre><code>- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif { // Handle the notificaton when the app is running NSLog(@"Recieved Notification %@",notif); app.applicationIconBadgeNumber=notif.applicationIconBadgeNumber++; UIApplicationState state = [app applicationState]; if (state == UIApplicationStateInactive) { // Application was in the background when notification // was delivered. [self localNotif]; } } - (void) localNotif { [self databaseOpen]; NSString *maxIdPt = [NSString stringWithFormat:@"select Max(id) from Points"]; NSLog(@"Max id from points table %@",maxIdPt); NSMutableArray *p1 = [[NSMutableArray alloc]init]; p1 = [[[database executeQuery:maxIdPt]mutableCopy]retain]; int p=[[[p1 objectAtIndex:0]valueForKey:@"Max(id)"]intValue]; NSLog(@"%d",p); NSString *maxPt = [NSString stringWithFormat:@"select Points from Points where id = %d",p]; NSLog(@"Maxp %@",maxPt); NSMutableArray * p2 = [[NSMutableArray alloc]init]; p2 =[[[database executeQuery:maxPt]mutableCopy]retain]; int k = [[[p2 objectAtIndex:0]valueForKey:@"Points"]intValue]; NSLog(@"Points %d",k); k = k + 250; NSLog(@"%d",k); NSString *mtpoints = [NSString stringWithFormat:@"insert into Points(Points) values (%d)",k]; NSLog(@" lbl Points are %@",mtpoints); NSMutableArray * m1 = [[NSMutableArray alloc]init]; m1 = [[[database executeQuery:mtpoints]mutableCopy]retain]; [database close]; } </code></pre> <p>The same method i called in <strong>application didFinishLaunchingWithOptions</strong></p> <p>First time the score is updated but second time it doesn't. Even the notification is not shown.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload