Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安卓机上load无法使用的问题 #147

Closed
ssshen opened this issue Dec 9, 2017 · 11 comments
Closed

安卓机上load无法使用的问题 #147

ssshen opened this issue Dec 9, 2017 · 11 comments

Comments

@ssshen
Copy link

ssshen commented Dec 9, 2017

系统:MIUI8

代码如下:
storage.js

import Storage from 'react-native-storage'
import { AsyncStorage } from 'react-native';


var storage = new Storage({
    size: 1000,
    storageBackend: AsyncStorage,
    defaultExpires: null,
	enableCache: true,
	sync : {
		
	}
})
global.storage = storage;

index.js

import { AppRegistry } from 'react-native';
import './app/util/storage'
...

使用的地方:

async function checkTokenExp() {
    var expTime = 0
    var token = ''
    var now = Date.parse(new Date()) / 1000
    console.log(now)
    await storage.load({'key': 'tokenExp'}).then(ret => {
        console.log(ret)
        token = ret
        var base64 = new Base64()
        var tokenInfoArr = token.split('.')
        let exp = base64.decode(tokenInfoArr[1])
        exp = exp.split('}')
        exp = exp[0] + '}'
        expTime = JSON.parse(exp).exp
    }).catch(err => {
        console.log(err)
    })
}

在iOS设备上面能够运行then里面的代码并打印出nowret,但是在android设备上面只能打印出now,没有打印ret也没有打印err

在iOS和android上使用方法不一样?

@sunnylqm
Copy link
Owner

似乎和这个有关 facebook/react-native#14101

@njgaoqing
Copy link

+1

@wwh0219
Copy link

wwh0219 commented Dec 14, 2017

怎么解决?

@sunnylqm
Copy link
Owner

等官方修复啊

@sunnylqm sunnylqm mentioned this issue Dec 19, 2017
@basilbai
Copy link

basilbai commented Feb 9, 2018

遇到了同样的问题,请问怎么解决

@Yibay
Copy link

Yibay commented Mar 20, 2018

同样在坑里,我的情况是,在Android Studio的模拟器运行时,load 失效,在测试用的Android真机中,load有效。坐等官方修复吧。。。

@lzctbyong
Copy link

lzctbyong commented Mar 23, 2018

添加权限可以解决
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
小伙伴们,试试

@felixzxk
Copy link

@lzctbyong thx

@xiaodehua
Copy link

添加权限可以解决

@lizhuoyuan
Copy link

我的偶尔会出现这个问题,重新启动app就好了 ,不知道是不是一样

@sunnylqm
Copy link
Owner

sunnylqm commented Aug 2, 2018

目前只影响android7+以及debug模式

预计0.57版本会修复这个问题
facebook/react-native@1b09bd7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants