ReactNative 低版本Jpush集成遇坑记录


对应jpush版本
“jcore-react-native”: “^1.8.0”
“jpush-react-native”: “^2.8.1”
对应Rn版本
“react-native”: “0.44.3”
相对版本较低,原来老项目需要进行改造集成推送,遇到坑跟码友共享,并自我记录,以便自身查看!

针对xcode11 报错

报错信息

getCurrentAppState:error

解决方法

在对应目录下/Users///node_modules/react-native/React/Base/RCTModuleMethod.m

static BOOL RCTParseUnused(const char **input)
{
     return RCTReadString(input, "__unused") ||
            RCTReadString(input, "__attribute__((__unused__))") ||    //lzj fixed
            RCTReadString(input, "__attribute__((unused))");
}

Error: Could not find iPhone 6 simulator

解决方法

在对应目录下/Users///node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js替换代码块

function findMatchingSimulator(simulators, simulatorName) {
  if (!simulators.devices) {
    return null;
  }
  const devices = simulators.devices;
  var match;
  for (let version in devices) {

    console.log(" version in devices ");
    console.log(version);

    // Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
    if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS')) {
      continue;
    }
    for (let i in devices[version]) {
      let simulator = devices[version][i];
      // Skipping non-available simulator
      if (simulator.isAvailable !== true) {
        continue;
      }
      let booted = simulator.state === 'Booted';
      if (booted && simulatorName === null) {
        return {
          udid: simulator.udid,
          name: simulator.name,
          booted,
          version
        };
      }
      if (simulator.name === simulatorName && !match) {
        match = {
          udid: simulator.udid,
          name: simulator.name,
          booted,
          version
        };
      }
      // Keeps track of the first available simulator for use if we can't find one above.
      if (simulatorName === null && !match) {
        match = {
          udid: simulator.udid,
          name: simulator.name,
          booted,
          version
        };
      }
    }
  }
  if (match) {
    return match;
  }
  return null;
}

module.exports = findMatchingSimulator;

Android低版本ContextCompat.checkSelfPermission不支持

解决方案

直接注释掉响应代码并将targetSdkVersion改成23,23版本不对权限做相应校验

notificationExtra没有toHashMap

解决方案

JPushModule.java中的方法将获取部分重写,通过迭代器去构造map

HashMap hashMap = new HashMap();
            ReadableMapKeySetIterator iterator = notificationExtra.keySetIterator();

            while (iterator.hasNextKey()){
                String nextValue  = iterator.nextKey();
                hashMap.put(nextValue,notificationExtra.getString(nextValue));
            }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值