React Native Async函数在IOS模拟器中失败



我有下面的简单代码,它们在Android中运行良好,但在IOS中等待不起作用。

const CheckAsyncfucntion = async () => {
console.log('Before Await execution');
const authenticateuser = await newUser(registration_id); // return true or false
console.log('After Await Execution => ', authenticateuser);
}

在Andodrid,它运行良好。但在ios中,两个日志都使用未定义的authenticateuser值进行打印。然后返回newUser值。

如有任何线索,我们将不胜感激。我使用IOS smiulator iphone12 IOS 15.0

我想问题出在函数newUser中。

我的iOS模拟器可以很好地使用下面的任何异步函数。

const CheckAsyncfucntion = async () => {
console.log('Before Await execution');
// return true or false from Promise
const authenticateuser = await new Promise((resolve, reject) => {
setTimeout(() => {
resolve(true);
}, 2000);
});
console.log('After Await Execution => ', authenticateuser);
};
CheckAsyncfucntion();

最新更新