V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
NonClockworkChen
V2EX  ›  问与答

RN 大神看下这个 iOS 的原生模块向 JS 发送事情,怎么写?

  •  
  •   NonClockworkChen · 2018-01-19 16:42:53 +08:00 · 1474 次点击
    这是一个创建于 2281 天前的主题,其中的信息可能已经有所发展或是发生改变。
    项目接入了阿里点播的 SDK.

    用 RCTViewManager 返回了一个 view 给 RN,可以播放.然后获得了视频的播放进度时间.

    需要用 RCTEventEmitter 发送事件给 JS 传递播放进度的时间.

    但是在 RCTViewManager 的类下面写了 RCTEventEmitter 的对象发送事件.

    xcode 就会报错.

    Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bridge is not set. This is probably because you've explicitly synthesized the bridge in PlayerModuleManager, even though it's inherited from RCTEventEmitter.'

    有没有大神指点一下.
    2 条回复    2018-01-19 16:58:26 +08:00
    NonClockworkChen
        1
    NonClockworkChen  
    OP
       2018-01-19 16:45:17 +08:00
    发完才想到报错信息,google 一下...好像有答案了...
    NonClockworkChen
        2
    NonClockworkChen  
    OP
       2018-01-19 16:58:26 +08:00
    issue 提到的没解决这个问题

    + (id)allocWithZone:(NSZone *)zone {
    static RNNotification *sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    sharedInstance = [super allocWithZone:zone];
    });
    return sharedInstance;
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3442 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 11:24 · PVG 19:24 · LAX 04:24 · JFK 07:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.