使用uni.login调用微信登录小程序、安卓App一路都很顺畅,但到了IOS,出现一个奇葩的事件,先来看,就是一段简单的登录代码
uni.login({
provider: 'weixin',
onlyAuthorize: true,
success: (res2) => {
console.log('getUserProfile:------4.')
},
fail: (res) => {
console.log('loginWechat.fail:', res)
},
complete:(res)=>{
console.log('..................')
}
});
在自定义基座的情况,如果你是在HbuilderX中调用基座执行,那么你会发现,无论任何情况,上面的代码执行都不会有问题。但如果你切换到Xcode中执行,那么问题来了,你首次调用uni.login时,也能正常返回,但如果第二次调用(30秒内调用),你会发现不管是success、fail、complete,三者不会有任何输出,也就是uni.login调用失败。那么,如何再次成功调用呢?答案是等30秒,为啥要等30秒呢?在30秒后,在Xcode中会输出一段警告日志,如下:
Background Task 3 ("Called by HBuilder, from -[AppDelegate applicationDidEnterBackground:]"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
你只能看到该日志输出后,你再次调用uni.login才会正常,我非专业的IOS开发,大体了解了一下,也就是说SDK中调用beginBackgroundTask,没有调用 endBackgroundTask,这个BUG有什么好的解决方法呢?还是说我哪没配置对?
0 个评论
要回复文章请先登录或注册