【问题标题】:Jawbone Moves not getting pulled in background refreshJawbone Moves 没有在后台刷新中被拉动
【发布时间】:2015-04-10 12:09:21
【问题描述】:

我已经使用https://github.com/Jawbone/UPPlatform_iOS_SDK 有一段时间了 并获取用户的日常步数。

我想在应用处于后台状态时从 Jawbone API 中提取数据。 我已按照本教程进行操作:http://www.devfright.com/ios-7-background-app-refresh-tutorial/ 调用此方法:

[UPMoveAPI getMovesWithLimit:10U completion:^(NSArray *moves, UPURLResponse *response, NSError *error) {
    NSLog(@"This is not getting executed in background");
}];

颚骨会话已成功验证,并且似乎我的会话处于活动状态。 但我没有得到回应,上面的 NSLog 没有在后台执行。 请我尝试联系 Jawbone 支持,他们似乎没有回复。

谁有同样的经历,请帮忙。

【问题讨论】:

    标签: ios iphone background refresh jawbone


    【解决方案1】:

    试试下面的代码选项:

    选项-1

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
       [UPMoveAPI getMovesWithLimit:10U completion:^(NSArray *moves, UPURLResponse *response, NSError *error) {
           NSLog(@"This is not getting executed in background");
       }];
    }
    

    选项 2 https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html

    bgTask = [application beginBackgroundTaskWithName:@"MyTask" expirationHandler:^{
            // Clean up any unfinished task business by marking where you
            // stopped or ending the task outright.
            [application endBackgroundTask:bgTask];
            bgTask = UIBackgroundTaskInvalid;
        }];
    
        // Start the long-running task and return immediately.
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    
            // Do the work associated with the task, preferably in chunks.
    
            [application endBackgroundTask:bgTask];
            bgTask = UIBackgroundTaskInvalid;
        });
    

    另请注意,您需要在 info.plist 中添加 UIBackgroundModes

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-05
      • 1970-01-01
      • 2021-05-19
      • 2015-02-04
      • 2016-03-30
      • 2015-05-12
      相关资源
      最近更新 更多