首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >后台刷新时未拉出Jawbone移动

后台刷新时未拉出Jawbone移动
EN

Stack Overflow用户
提问于 2015-02-10 20:44:19
回答 1查看 233关注 0票数 0

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

我想在应用程序处于后台状态时从Jawbone API中提取数据。我遵循这个教程:http://www.devfright.com/ios-7-background-app-refresh-tutorial/来调用这个方法:

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

jawbone会话已成功验证,并且我的会话似乎处于活动状态。但是我没有得到响应,上面的NSLog也不会在后台执行。我已经联系过Jawbone支持,他们似乎没有回复。

任何有同样经历的人,请帮助。

EN

回答 1

Stack Overflow用户

发布于 2015-02-19 18:40:51

尝试下面的代码选项:

选项-1\f25-1\f6

代码语言:javascript
复制
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\f25 https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html -2\f6

代码语言:javascript
复制
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

希望这能有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28432030

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档