set localnotification

    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){

        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];

    }

    if([[NSUserDefaults standardUserDefaults]valueForKey:@”rate”]==NULL)

    {

        

        NSDate *now = [NSDate date];

        NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];

        NSDateComponents *components = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay fromDate:now];

        [components setHour:21];

        //[components setMinute:13];

        //    [components setSecond:00];

        NSDate *next9am = [calendar dateFromComponents:components];

        if ([next9am timeIntervalSinceNow] < 0) {

            

            next9am = [next9am dateByAddingTimeInterval:60*60*24];

        }

        UILocalNotification *notification = [[UILocalNotification alloc] init];

        notification.fireDate = next9am;

        notification.alertBody = @”If you enjoy using Photo Background Eraser, would you mind taking a moment to rate it? It won’t take more than a minute. Thanks for your support!”;

        

        notification.repeatInterval = NSCalendarUnitDay;

        notification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;

        [[UIApplication sharedApplication] scheduleLocalNotification:notification];

    }

     [self notinapp];

    [self SetUpGoogleaddregister];

    

    

    

    return YES;

}

– (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

{

    

    UIViewController *VC=((UINavigationController*)self.window.rootViewController).visibleViewController;

    

    UIAlertController * alert=   [UIAlertController

                                  alertControllerWithTitle:@”Alert”

                                  message:@”If you enjoy using Photo Background Eraser, would you mind taking a moment to rate it? It won’t take more than a minute. Thanks for your support!”

                                  preferredStyle:UIAlertControllerStyleAlert];

    

    UIAlertAction *Cancel = [UIAlertAction actionWithTitle:@”Cancel” style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){

        //do something when click button

    }];

    UIAlertAction *Purchase = [UIAlertAction actionWithTitle:@”Rate” style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){

        [[NSUserDefaults standardUserDefaults] setObject:@”abc” forKey:@”rate”];

        NSURL *url = [NSURL URLWithString:@”https://itunes.apple.com/us/app/photo-background-eraser/id1115119896?mt=8&#8243;];

        [[UIApplication sharedApplication] openURL:url];

    }];

    

    [alert addAction:Purchase];

    [alert addAction:Cancel];

    

    [VC presentViewController:alert animated:YES completion:nil];

    

}

Leave a comment

search previous next tag category expand menu location phone mail time cart zoom edit close