NonClockworkChen
V2EX  ›  问与答

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

  •  
  •   NonClockworkChen · Jan 19, 2018 · 1820 views
    This topic created in 3038 days ago, the information mentioned may be changed or developed.
    项目接入了阿里点播的 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 replies    2018-01-19 16:58:26 +08:00
    NonClockworkChen
        1
    NonClockworkChen  
    OP
       Jan 19, 2018
    发完才想到报错信息,google 一下...好像有答案了...
    NonClockworkChen
        2
    NonClockworkChen  
    OP
       Jan 19, 2018
    issue 提到的没解决这个问题

    + (id)allocWithZone:(NSZone *)zone {
    static RNNotification *sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    sharedInstance = [super allocWithZone:zone];
    });
    return sharedInstance;
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2903 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 12:02 · PVG 20:02 · LAX 05:02 · JFK 08:02
    ♥ Do have faith in what you're doing.