jpush / jpush-react-native

JPush's officially supported React Native plugin (Android & iOS). 极光推送官方支持的 React Native 插件(Android & iOS)。
http://docs.jiguang.cn
MIT License
1.35k stars 336 forks source link

Android在当前界面点击通知重启app再跳转指定页面(后台运行一切正常) #482

Closed fengye1 closed 6 years ago

fengye1 commented 6 years ago

你的运行环境

期望效果

在接到通知后点击直接跳转当目标界面

实际效果

现在是在点击通知后重启一次app在跳转到目标界面(只有在当前界面的时候这样,在后台运行时是正常的)

重现步骤

  1. 运行 APP,接收通知,在app界面中 去点击通知栏的通知栏,

Debug logs

`componentDidMount() {

    BackHandler.addEventListener("hardwareBackPress", this.onBackPress);

    if (Platform.OS === 'android') {
        JPushModule.initPush()
        JPushModule.getInfo(map => {
          this.setState({
            appkey: map.myAppKey,
            imei: map.myImei,
            package: map.myPackageName,
            deviceId: map.myDeviceId,
            version: map.myVersion
          },()=>{
              console.log("----------state-------",this.state)
          })
        })
        JPushModule.notifyJSDidLoad(resultCode => {
          if (resultCode === 0) {
          }
        })
      } else {
        JPushModule.setupPush()
      }

    JPushModule.notifyJSDidLoad((resultCode) => {
        console.log("---notifyJSDidLoad---", resultCode)
    });
    JPushModule.addReceiveNotificationListener((message) => {
        const { dispatch, nav } = this.props;
        dispatch(setNotificationStatus(true))
    })

    JPushModule.addReceiveOpenNotificationListener((map) => {
        console.log("addReceiveOpenNotificationListener", map)
        const { dispatch, nav } = this.props;
        dispatch(NavigationActions.navigate({routeName: 'Notification'}))
    });

  }

`

fengye1 commented 6 years ago

有人出现这种情况吗

SanlinBlackball commented 6 years ago

@fengye1 请问问题解决了吗

JoshLipan commented 6 years ago

可以试下官方的sample,我这边测试是没有这个问题的

fengye1 commented 6 years ago

我的还有这个问题,我试一下官方的例子吧

fengye1 commented 6 years ago

@JoshLipan 官方的例子我运行起来了,但是我怎样去模拟这个操作呀,我无法模拟推送,弹到通知栏

JoshLipan commented 6 years ago

app/build.gradle下applicationId改成自己在极光后台配置的包名,APPkey也改成对应的试试

default
fengye1 commented 6 years ago

好的谢谢,我试一下,反馈真快,感谢

fengye1 commented 6 years ago

问题解决了,解决方法:可以查看一下对应的Android的AndroidManifest.xml 文件跟截图对应一下,需要更改 android的启动方式 android:launchMode="singleTask"

1526621480 1