Comments (3)
已解决了
我的场景是:进入到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.
可能代码需要加一些保护
RCT_EXPORT_METHOD(getDeviceId:(RCTResponseSenderBlock)callback)
{
NSString *deviceId = [CloudPushSDK getDeviceId];
if (deviceId==Nil) deviceId = @""; // 加这一行看看?不会报错, 失败返回空串
callback(@[deviceId]);
}
from react-native-aliyun-push.
v1.0.12 改进一下做法。
getDeviceId()逻辑处理变更为一次取得失败后延迟三秒再次获取
getDeviceId()接口变更为Promise模式,可以增加取得失败处理。
from react-native-aliyun-push.
Related Issues (20)
- iOS 收到通知后,点击通知,启动APP仅停留在首页,不跳转到对应参数页面
- alicloud-android-utdid-1.1.5.4 相关
- ios 后台运行的时候不触发监听 HOT 2
- [Android] How do I override MessageReceiver HOT 1
- not work android(Task :app:processDebugManifest FAILED) HOT 2
- 请问安卓离线推送时,服务端怎么填推送路径呢? HOT 1
- 请问如何配合服务端的badge 角标自增长?怎样监听APP在后台时获取到通知呢? HOT 1
- 厂商通道小米 HOT 1
- 杀死app的情况下,使用小米厂商通道,收到了通知但是点击通知不能唤起app HOT 3
- Feature request: A way to determine wether to display notification or not while app is at foreground
- app偶发闪退问题
- 在ios上面报编译错误 :use of undeclare identifier "AliyunPushManager" HOT 1
- 安卓打包release后获取不到deviceId
- How to remove the operation of app initialization to obtain notification permission HOT 4
- When you close the APP, you don't receive notifications. When you open the APP, you receive notifications HOT 11
- Android vendor channel received message corner markers cannot be set
- 麻烦问下 ios的集成有案例吗,我想看一下,我这边始终配不好 HOT 1
- 安卓集成后,app在后台如何点击推送唤醒app HOT 1
- Android12的匹配方案-已完成并验证上架
- 手动关闭接收推送
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-aliyun-push.