|
@@ -62,7 +62,13 @@
|
|
|
|
|
|
|
|
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
|
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
|
|
|
|
|
|
|
|
|
+ if(self.occupied)
|
|
|
|
|
+ {
|
|
|
|
|
+ completionHandler(UIBackgroundFetchResultNoData);
|
|
|
|
|
+ return; // 不处理后台时的推送,避免重复推送
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ self.occupied = true;
|
|
|
if(application.applicationState == UIApplicationStateInactive)
|
|
if(application.applicationState == UIApplicationStateInactive)
|
|
|
{
|
|
{
|
|
|
completionHandler(UIBackgroundFetchResultNoData);
|
|
completionHandler(UIBackgroundFetchResultNoData);
|
|
@@ -107,6 +113,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 取消所有推送
|
|
|
|
|
+ [application setApplicationIconBadgeNumber:0];
|
|
|
|
|
+
|
|
|
|
|
+// UNUserNotificationCenter * center = [UNUserNotificationCenter currentNotificationCenter];
|
|
|
|
|
+// [center removeAllPendingNotificationRequests];
|
|
|
|
|
+ // 弹出提示框
|
|
|
|
|
+
|
|
|
UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Local Data Update Required" message:nil preferredStyle:UIAlertControllerStyleAlert];
|
|
UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Local Data Update Required" message:nil preferredStyle:UIAlertControllerStyleAlert];
|
|
|
//block代码块取代了delegate
|
|
//block代码块取代了delegate
|
|
|
|
|
|
|
@@ -119,7 +133,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ self.occupied = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
}];
|
|
}];
|
|
@@ -129,6 +143,8 @@
|
|
|
[RADataProvider updateTemplate:vc];
|
|
[RADataProvider updateTemplate:vc];
|
|
|
|
|
|
|
|
[RADataProvider updateStock:vc];
|
|
[RADataProvider updateStock:vc];
|
|
|
|
|
+
|
|
|
|
|
+ self.occupied = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
}];
|
|
}];
|
|
@@ -138,6 +154,7 @@
|
|
|
[alertControl addAction:alertthree];
|
|
[alertControl addAction:alertthree];
|
|
|
|
|
|
|
|
UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Update Later" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Update Later" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
|
|
|
+ self.occupied = false;
|
|
|
}];
|
|
}];
|
|
|
[alertControl addAction:alertcancel];
|
|
[alertControl addAction:alertcancel];
|
|
|
|
|
|