Giter Club home page Giter Club logo

Comments (3)

Covenanter avatar Covenanter commented on August 21, 2024

已解决了
我的场景是:进入到APP的时候就调用获取deviceId的方法获取deviceId,然后根据deviceId做别的事情。
大致跟了下源代码,发现在初始化方法的时候会异步调用阿里的api获取deviceId。

分析:
app启动时获取deviceId,这个动作是异步的,由于在debug模式下打印日志之类的动作所花费的时间足够api生成deviceId,因此,在debug模式下是正常的。
在生成ipa也就是生成模式下,打印日志或调试之类的动作将被取消,所以api执行的时间并不足以获取deviceId,在调用获取deviceId的时候,objectc将一个空置赋值到一个数组中造成了异常,也就是最直接的闪退现象。

不知道我以上的分析对不对。
解决办法:
在获取deviceId的时候使用延迟获取

setTimeout(()=>{ 这里填写获取deviceId的方法 },2000)
就能得到deviceId

from react-native-aliyun-push.

wonday avatar wonday commented on August 21, 2024

可能代码需要加一些保护

RCT_EXPORT_METHOD(getDeviceId:(RCTResponseSenderBlock)callback)
{
    NSString *deviceId = [CloudPushSDK getDeviceId];
    if (deviceId==Nil) deviceId = @""; // 加这一行看看?不会报错, 失败返回空串
    callback(@[deviceId]);
}

from react-native-aliyun-push.

wonday avatar wonday commented on August 21, 2024

v1.0.12 改进一下做法。
getDeviceId()逻辑处理变更为一次取得失败后延迟三秒再次获取
getDeviceId()接口变更为Promise模式,可以增加取得失败处理。

from react-native-aliyun-push.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.