0
我在我的遊戲應用程序中實施了一個本地通知,每天發送一次每日獎勵。當我點擊通知橫幅時,這一切都正常,但是,當我從應用程序圖標進入應用程序時,本地通知無法正常工作。本地通知
這裏是我的代碼:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions{
.......
.......
application.applicationIconBadgeNumber = 0;
UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif)
{
NSLog(@"recieved notification %@",localNotif);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Daily Bonus"
message:@"You recieved 100 free coins"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"ok", nil];
[alert show];
[alert release];
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
float balance = [standardUserDefaults floatForKey:kCurrentScore];
balance +=100.0f;
NSLog(@"%g",balance);
[standardUserDefaults setFloat:balance forKey:kCurrentScore];
[standardUserDefaults synchronize];
}
我希望得到任何幫助。