当计时器达到1分钟时发送通知

时间:2015-09-24 14:06:33

标签: ios notifications

我正在为iPhone创建一个应用程序,我需要通知(不是通知,告诉您再次玩游戏)。我需要一个通知,告诉用户你已经完成了什么。

关闭时,我已经在我的应用程序的后台运行了一个计时器。我只想说,当计时器开启1分钟时告诉玩家它完成了通知。

-(IBAction)deathmatchstart:(id)sender{
    UIBackgroundTaskIdentifier bgTask = 0;
    UIApplication  *app = [UIApplication sharedApplication];
    bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
        [app endBackgroundTask:bgTask];
    }];
    DeathMatchTime = [NSTimer scheduledTimerWithTimeInterval:1      
    target:self selector:@selector(startdeathmatch) userInfo:nil
    repeats:YES];

    DeathMatchLabel.hidden = NO;
    DeathMatchStart.hidden = YES;
}

-(void)startdeathmatch {
    deathmatchcount = deathmatchcount +1;

    DeathMatchLabel.text = [NSString stringWithFormat:@"%i:%i", deathmatchcountmin, deathmatchcount];

    if(deathmatchcount == 59){
        deathmatchcountmin = deathmatchcountmin +1;
        deathmatchcount = 0;
    }
    // CHANGE TO 8
    if(deathmatchcountmin == 1) {
        DeathMatchDone.hidden = NO;
        DeathMatchLabel.hidden = YES;
        getReward.hidden = NO;

    }
}

0 个答案:

没有答案
相关问题