1

ur 계정에 게시물 메시지 기능을 추가 한 애플리케이션을 작성 중입니다. 이제이 시설에서 일정을위한 이벤트를 추가하고 있습니다. 해당 사용자의 도움으로 메시지를 작성하고 나중에 또는 특정 날짜와 시간에 메시지를 게시 할 수 있습니다. 이를 위해 사용자가 지정한 날짜에 생성하는 로컬 알림 이벤트를 사용했습니다. 그러나 문제는 알림이 생성 될 때 페이스 북에서 게시 메시지에 사용되는 함수를 호출한다는 것입니다. 대한 알림을 생성 나는이 코드를 사용하고 있습니다 :fb에 메시지 게시로 이벤트 스케줄링을 구현하는 방법

-(IBAction)save{ 
    NSString *str1=[NSString stringWithFormat:@"%@",txt_date.text]; 
    NSString *str2=[NSString stringWithFormat:@" %@",txt_time.text]; 
    str1=[str1 stringByAppendingFormat:str2]; 
    selected_label.text= str1; 
    [[UIApplication sharedApplication] cancelAllLocalNotifications]; 
    NSDate *today=[NSDate date]; 
    NSDateFormatter* formatter_current = [[[NSDateFormatter alloc] init] autorelease]; 
    formatter_current.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; 
    //Set the required date format 
    [formatter_current setDateFormat:@"yyyy-MM-dd hh:mm a"]; 

    NSLog(@"current date is =%@",str1); 
    today=[formatter_current dateFromString:str1]; 
    NSLog(@"current date:-%@",today); 
    UILocalNotification* ln = [[UILocalNotification alloc] init]; 
    ln.alertBody = @"Wake Up Sid"; 
    ln.applicationIconBadgeNumber = 1; 
    ln.fireDate = today; //[NSDate dateWithTimeIntervalSinceNow:15]; 
    ln.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; 
    NSLog(@"alarm will activate on%@",today); 
    NSDateFormatter* formatter_alarm = [[[NSDateFormatter alloc] init] autorelease]; 
    NSLocale *uslocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; 
    [formatter_alarm setLocale:uslocale]; 
    [uslocale release]; 
    formatter_alarm.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; 
    [formatter_alarm setDateFormat:@"hh:mm a"]; 
    NSString *str=[formatter_alarm stringFromDate:today]; 
    NSLog(@"%@",str); 
    ln.alertBody = [NSString stringWithFormat:@"Your first appointment at %@",str]; 
    ln.soundName = UILocalNotificationDefaultSoundName; 
    ln.repeatInterval=NSDayCalendarUnit; 
    [[UIApplication sharedApplication] scheduleLocalNotification:ln]; 
    [ln release]; 
} 

및 AppDelegate에 파일에 내가받은 알림 및 전화 포스트 메시지 기능이 기능을 사용

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 
// Override point for customization after application launch. 

    self.viewController=[[demo_social_updatesViewController alloc]initWithNibName:@"demo_social_updatesViewController" bundle:nil]; 
    nav_controller=[[UINavigationController alloc] initWithRootViewController:self.viewController]; 
    // Add the view controller's view to the window and display. 
    [self.window addSubview:nav_controller.view]; 
    [self.window makeKeyAndVisible]; 
    appDelegate_acess_token=[[NSUserDefaults standardUserDefaults] stringForKey:@"access_token"]; 
     application.applicationIconBadgeNumber = 0; 
    // Handle launching from a notification 
    UILocalNotification *localNotif = 
    [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; 
    if (localNotif) { 
     NSLog(@"Recieved Notification %@",localNotif); 
    } 
    return YES; 
} 

- (void)applicationDidEnterBackground:(UIApplication *)application{ 
    if (application.applicationIconBadgeNumber == 1) { 
     BOOL tmp=[Global_Class_parsing post_comment_fb:appDelegate_acess_token uesr_comment:@"testing message111"]; 
     if(tmp){ 

      UIAlertView *av = [[[UIAlertView alloc] initWithTitle:@"Sucessfully posted to photos & wall!" 
                  message:@"Check out your Facebook to see!" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil] autorelease]; 
      [av show]; 

     } 
     else{ 
      UIAlertView *av = [[[UIAlertView alloc] initWithTitle:@"error"message:@"Check connection!" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil] autorelease]; 
      [av show]; 
     } 
    } 

    /* 
    Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 
    */ 
} 

- (void)applicationWillEnterForeground:(UIApplication *)application{ 
    /* 
    Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 
    */ 
    if (application.applicationIconBadgeNumber == 1) { 
     BOOL tmp=[Global_Class_parsing post_comment_fb:appDelegate_acess_token uesr_comment:@"testing message111"]; 
     if(tmp){ 

      UIAlertView *av = [[[UIAlertView alloc] initWithTitle:@"Sucessfully posted to photos & wall!" 
                  message:@"Check out your Facebook to see!" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil] autorelease]; 
      [av show]; 

     } 
     else{ 
      UIAlertView *av = [[[UIAlertView alloc] initWithTitle:@"error"message:@"Check connection!" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil] autorelease]; 
      [av show]; 
     } 
    } 
} 

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { 
    UIApplicationState state = [application applicationState]; 
    if (state == UIApplicationStateInactive) { 
     NSLog(@"Recieved Notification %@",notification); 
    } else { 
     NSLog(@"Recieved Notification method call."); 
    } 
} 

이제 문제를 그 통지를 생성하고 applicationbadge 수 때 1이되면 어떤 함수도 호출하지 않고 내 포스트 메시지 함수는 호출하지 않습니다. 그래서 어떻게 그 오류를 수정?

+1

가능한 [중복 된 이유는 무엇입니까?] (http://stackoverflow.com/questions/8410638/why-didrecivedlocalnotification-method-not-working). 다시 질문하기보다는 원래의 질문을 다시 작성하기 만하면됩니다. – Abizern

답변

1

이 질문에 대한 해결책을 얻으려면 게시 방법으로 일정을 구현하는 두 가지 방법이 있습니다. 단순히 알림을 사용하는 것입니다. 또 하나는 웹 서비스를 사용하는 것입니다. 나는 둘 다 잘 사용하고 있습니다.