我用的极光IM小程序SDK,使用到UNI框架中开发APP,发现每隔几分钟总是掉线
```
// 异常断线监听
export function OnDisconnectJIM() {
Vue.prototype.$JIM.onDisconnect(function() {
console.log('<----极光IM断线监听---->')
uni.showToast({
title:'检测到极光IM断线',
icon: 'none'
})
ReInitJIM()
})
}
function ReInitJIM(){
uni.showToast({
title:'尝试重新连接极光IM...',
icon: 'none'
})
InitJIM().then(() => {
console.log('<----断线后再次初始化成功---->')
uni.showToast({
title:'重新连接极光IM成功',
icon: 'none'
})
ReLoginJIM()
}).catch(() => {
console.log('<----断线后再次初始化失败---->')
uni.showToast({
title:'重新连接极光IM失败',
icon: 'none'
})
ReInitJIM()
})
}
function ReLoginJIM(){
uni.showToast({
title:'尝试重新登陆极光IM...',
icon: 'none'
})
var userInfo = uni.getStorageSync('USERS_INFO')
if(userInfo){
var account = JSON.parse(userInfo)
LoginJIM(account.userid).then(function() {
console.log('<----断线后再次登陆成功---->')
uni.showToast({
title:'重新登陆极光IM成功',
icon: 'none'
})
}).catch(() => {
console.log('<----断线后再次登陆失败---->')
uni.showToast({
title:'重新登陆极光IM失败',
icon: 'none'
})
ReLoginJIM()
})
}
}