Created
December 3, 2013 01:55
-
-
Save neiraza/7762630 to your computer and use it in GitHub Desktop.
Background Fetch (iOS7) sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ([UiUtil isNotLessiOS7]) { | |
//UIApplicationBackgroundFetchIntervalMinimum or NN seconds | |
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:600]; | |
} | |
- (void)updateAppIconBadge | |
{ | |
LOG(@">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>updateAppIconBadge<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); | |
// 設定する前に、設定済みの通知をキャンセルする | |
UILocalNotification *localNotification = [UILocalNotification new]; | |
localNotification.alertAction = @"キタ━━━━(゚∀゚)━━━━!!"; | |
localNotification.alertBody = @"('A`)マンドクセ ('A`)マンドクセ ('A`)マンドクセ"; | |
localNotification.fireDate = [NSDate date]; | |
localNotification.timeZone = [NSTimeZone localTimeZone]; | |
localNotification.soundName = UILocalNotificationDefaultSoundName; | |
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; | |
} | |
-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler | |
{ | |
[self updateAppIconBadge]; | |
// 失敗時には UIBackgroundFetchResultFailed を渡して completionHandler を呼ぶ | |
//completionHandler(UIBackgroundFetchResultFailed); | |
// 成功時には UIBackgroundFetchResultNewData を渡して completionHandler を呼ぶ | |
completionHandler(UIBackgroundFetchResultNewData); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SystemCapabilities = { | |
com.apple.BackgroundModes = { | |
enabled = 1; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment