[关闭]
@garygchai 2016-07-12T11:07:52.000000Z 字数 5588 阅读 2040

reactnative与原生对接文档整理

reactnative


reactnative注册给native集成的组件

native提供给reactnative调用的API

第1类,系统级manager,如:ReactNativeManager

ReactNativeManager

  1. React.NativeModules.ReactNativeManager.getRequestUrl((serviceUrl) => {
  2. //serviceUrl: http://live.kugou.com
  3. });
  1. React.NativeModules.ReactNativeManager.getClientInfo((clientInfo) => {
  2. //clientInfo: offset=0&size=20&sign=3b9bfb69dbd95679&version=6572&platform=5
  3. var url = serviceUrl + '/mv/cdn/getMvList4Native?' + clientInfo;
  4. });
  1. React.NativeModules.ReactNativeManager.getUserInfo((userInfo) => {
  2. //TODO
  3. });
  1. React.NativeModules.ReactNativeManager.requestError("请求出错!");

第2类,业务级manager,如:KugouLiveManager

暂无

第3类,页面级manager,如:LiveReviewManagerConcertPageManager

LiveReviewManager

  1. React.NativeModules.LiveReviewManager.currentUrlCallback((serviceUrl) => {
  2. //serviceUrl: http://live.kugou.com
  3. });
  1. React.NativeModules.LiveReviewManager.getClientInfo((clientInfo) => {
  2. //clientInfo: offset=0&size=20&sign=3b9bfb69dbd95679&version=6572&platform=5
  3. var url = serviceUrl + '/mv/cdn/getMvList4Native?' + clientInfo;
  4. });
  1. React.NativeModules.LiveReviewManager.requestListError("请求出错!");
  1. React.NativeModules.LiveReviewManager.playNextMvWith(hash, title);

ConcertPageManager

  1. {
  2. concertId: 331,
  3. concertType: 1,
  4. coverImg: "http://image.fanxing.kugou.com/fansbanner/20160627/20160627111739764595.jpg",
  5. endTime: 1467811525088,
  6. h5Switch: 0,
  7. onlineCount: 0,
  8. playNum: 1386,
  9. roomId: 0,
  10. singer: "魏晨",
  11. starNum: 59161,
  12. startTime: 1467804604000,
  13. status: 2,
  14. subscribeCount: 0,
  15. summaryContent: "魏晨白日梦想家分享会,和魏晨的亲密约会,等你来赴约!说、唱、问、答、玩,花式互动360度全方位满足你的“白日梦想”。“橙”意十足,“魏”你而来!",
  16. title: "魏晨·白日梦想家分享会",
  17. vipSwitch: 0
  18. });
  19. React.NativeModules.ConcertPageManager.enterKugouLiveRoom(
  20. concertId, concertTitle, vipSwitch, h5Switch, h5Url
  21. );
  1. var json = JSON.parse({
  2. concertId: 331,
  3. concertType: 1,
  4. coverImg: "http://image.fanxing.kugou.com/fansbanner/20160627/20160627111739764595.jpg",
  5. endTime: 1467811525088,
  6. h5Switch: 0,
  7. onlineCount: 0,
  8. playNum: 1386,
  9. roomId: 0,
  10. singer: "魏晨",
  11. starNum: 59161,
  12. startTime: 1467804604000,
  13. status: 2,
  14. subscribeCount: 0,
  15. summaryContent: "魏晨白日梦想家分享会,和魏晨的亲密约会,等你来赴约!说、唱、问、答、玩,花式互动360度全方位满足你的“白日梦想”。“橙”意十足,“魏”你而来!",
  16. title: "魏晨·白日梦想家分享会",
  17. vipSwitch: 0
  18. });
  19. React.NativeModules.ConcertPageManager.enterKugouLiveReviewPage(json);
  1. React.NativeModules.ConcertPageManager.enterKugouLiveSubscribePage(concertId, h5Url, subscribe);

reactnative注册给native调用的事件

  1. NativeAppEventEmitter.addListener('playNext', () => {
  2. liveReviewManager.playNextMvWith(hash, title);
  3. });

相关数据接口补充

  1. {
  2. code: 0,
  3. data: [{
  4. concertId: 130,
  5. concertType: 1,
  6. coverImg: "http://s10.fxwork.fanxing.com/fansbanner/20160425/20160425135751755982.jpg",
  7. currentTime: 0,
  8. endTime: 0,
  9. h5Switch: 0,
  10. h5Url: "http://test.m.fanxing.com/static/mobile/kugouLive/views/liveDetail.html?concertId=130",
  11. onlineCount: 0,
  12. playNum: 0,
  13. roomId: 1013544,
  14. singer: "黄子韬",
  15. starNum: 0,
  16. startTime: 1464775277000,
  17. status: 0,
  18. subscribeCount: 0,
  19. title: "枕头大战测试",
  20. vipSwitch: 0
  21. }],
  22. msg: "操作成功",
  23. times: 1468287265
  24. }
  1. {
  2. code: 0,
  3. data: [{
  4. concertId: 331,
  5. concertType: 1,
  6. coverImg: "http://image.fanxing.kugou.com/fansbanner/20160627/20160627111739764595.jpg",
  7. endTime: 1467811525088,
  8. h5Switch: 0,
  9. onlineCount: 0,
  10. playNum: 1386,
  11. roomId: 0,
  12. singer: "魏晨",
  13. starNum: 59161,
  14. startTime: 1467804604000,
  15. status: 2,
  16. subscribeCount: 0,
  17. summaryContent: "魏晨白日梦想家分享会,和魏晨的亲密约会,等你来赴约!说、唱、问、答、玩,花式互动360度全方位满足你的“白日梦想”。“橙”意十足,“魏”你而来!",
  18. title: "魏晨·白日梦想家分享会",
  19. vipSwitch: 0
  20. }],
  21. msg: "操作成功",
  22. times: 1468287265
  23. }
  1. {
  2. code: 0,
  3. data: {
  4. 1: false,
  5. 50: false,
  6. 51: false,
  7. 53: false,
  8. 59: false,
  9. 83: false,
  10. 86: true,
  11. 130: true
  12. },
  13. msg: "SUCCESS",
  14. times: 1468292552
  15. }
  1. {
  2. code: 0,
  3. data: {
  4. concertId: 88,
  5. coverUrl: "http://s10.fxwork.fanxing.com/fansbanner/20160510/20160510171934396603.jpg",
  6. listMv: [
  7. {
  8. hash: "5B8E19EC11AFB5DE5E996E7F9728EC5F",
  9. mvId: 1,
  10. singer: "通知推送测试",
  11. summaryContent: "通知推送测试",
  12. title: "通知推送测试"
  13. }
  14. ],
  15. starNum: 0,
  16. startTime: 1464604214000,
  17. summaryContent: "",
  18. vipSwitch: 0
  19. },
  20. msg: "操作成功",
  21. times: 1468292688
  22. }
  1. //POST 请求
  2. sign=0dbf4a5ac0dfbcb8&appid=1131&channel=200&concertId=53&device=867516028242417%2458%3A44%3A98%3Abe%3A94%3Ae1&islogin=1&kugouId=842813124&muuid=ad58195b1e6abf7169c8f5414f3eedb4&phoneNum=0&pid=842813124&platform=5&sysVersion=21&times=1468289365849&token=6004dc4909f525a1e42ce1bf432ec2fb86b2635e66d515e986d34d782779329b&type=1&version=6575

返回:

  1. {
  2. "code":0,
  3. "data":
  4. {"1":false,"59":false,"50":false,"83":false,"51":false,"130":true,"53":false,"86":true
  5. },
  6. "msg":"SUCCESS",
  7. "times":1468289367
  8. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注