帖子
帖子
用户
博客
课程
显示全部楼层
12
帖子
0
勋章
798
Y币

[多端开发] 推送点击通知,跳转APP

[复制链接]
发表于 2024-3-26 16:28:55
需求:点击通知,打开APP,并通过后台api所传参数,跳转到对应页面

问题:点击通知,无法打开APP,下面两种接收方式也都无法接收

使用的推送模块是:tpnsPushPlus
PHP后端api代码:
                require_once("tpns.php");
                $android = new tpns\AndroidMessage;
                $android->n_ch_id = "chid";
                $action=new tpns\AndroidAction;
                $action->action_type = 3;
                $action->intent = "myapp://index?id=12345";
                $android->action = $action;

                $req = tpns\NewRequest(
                    tpns\WithAudienceType(tpns\AUDIENCE_TOKEN_LIST),
                    tpns\WithMessageType(tpns\MESSAGE_NOTIFY),
                    tpns\WithTitle("标题"),
                    tpns\WithContent("xxx消息"),
                    tpns\WithAndroidMessage($android),
                    // tpns\WithIOSMessage($ios),
                    tpns\WithTokenList(array("02f958c01842b4a34c9badb0f429703285f0")),
                    tpns\WithEnvironment(tpns\ENVIRONMENT_PROD)
                );

APP  config.xml配置
    <intent-filter>
        <action name="android.intent.action.VIEW"/>
        <category name="android.intent.category.DEFAULT"/>
       <data scheme="myapp" host="" path="/index"/>
    </intent-filter>


APP接收代码:
第一种
    document.addEventListener('appReadystart', function(e) {

api.addEventListener({

    name: 'appLaunch',

    extra: {

        type: 'url'

    },

    callback: function(ret, err) {

        var url = ret.url;
        console.log(url)
        if (url.startsWith('myapp://index?id=')) {

            var id = url.split('=')[1];

            // 根据id加载并展示详情内容

            // displayDetails(id);

        }

    }

});

});

第二种



    api.addEventListener({
                            name: 'appintent'
                        }, function (ret, err) {
                            console.log("addEventListener-appintent" + JSON.stringify(ret));
                            var appParam = ret.appParam;
                        });





Arly【770104707】
130
帖子
7
勋章
5万+
Y币
最佳答案
config.xml 里面的配置了吗?
文档:
腾讯信鸽厂商推送申请地址腾讯信鸽厂商推送

插件依赖

注意:
1.使用本插件需要上传【hmsCore】扩展插件包,配合使用(【自定义插件教程】)

2.如遇见其他问题请联系*****
------------------------------------------------------------------
建议再看一下文档是不是有没有配置的,文档中说的依赖上传了没有,建议直接联系开发人员,文档中有联系方式。
130
帖子
7
勋章
5万+
Y币
config.xml  里面的
  1. <preference name="urlScheme" value="myapp"/>
复制代码
配置了吗?
130
帖子
7
勋章
5万+
Y币
  1. <intent-filter>
  2.         <action name="android.intent.action.VIEW"/>
  3.         <category name="android.intent.category.DEFAULT"/>
  4.        <data scheme="myapp" host="【包名】" path="/index"/>
  5.     </intent-filter>
复制代码


host 填写一下自己的应用包名
您需要登录后才可以回帖 登录

本版积分规则