npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-tpns-remake

v1.0.0

Published

Remake the tpns cordova plugin due to old version doesn't contain ios :)

Downloads

2

Readme

cordova-plugin-tpns-remake

为Cordova项目接入新版本TPNS SDK

TPNS SDK版本

  • iOS SDK v1.3.9.5
  • Android SDK 待定

接入说明

在项目中安装插件

cordova plugin add https://github.com/tadazly/cordova-plugin-tpns-remake.git --variable TPNS_ACCESS_ID=1600007893 --variable TPNS_ACCESS_KEY=IX4BGYYG8L4L

TPNS_ACCESS_ID 和 TPNS_ACCESS_KEY 腾讯云任务中心=>App推送管理=>基础配置 中获取自行提换

项目配置

  • iOS
    • 搜索路径设置

      1. 项目配置选中你的TARGETS => app => Build Settings
      2. Framework Search Paths 添加 "你的app名字/Plugins/cordova-plugin-tpns-remake"
      3. Library Search Paths 添加 "$(SRCROOT)/$(TARGET_NAME)/Plugins/cordova-plugin-tpns-remake"
    • 参照SDK文档-工程配置完成工程配置

      1. 项目配置选中你的TARGETS => app => Signing & Capabilities
      2. 点击 +Capability 按钮
      3. 搜索并添加 Push Notifications、Background Modes(勾选Remote notifications)、Time Sensitive Notifications

使用方式

  1. (可选,默认开启)设置Debug输出
    tpns.setEnableDebug(true);
  1. (可选,默认使用上海域名)设置域名接口
    tpns.setConfigHost(tpns.TPNS_DOMAIN.SH);
  1. (可选)添加收到通知、点击通知的监听
    // 添加收到消息时触发的回调函数
    tpns.addNotificationListener((data) => {
        if (data && data.aps) {
            // ...
        }
        if (data && data.xg) {
            // ...
        }
    });
    // 添加点击消息时触发的回调函数
    tpns.addResponseListener((data) => {
        if (data && data.aps) {
            // ...
        }
        if (data && data.xg) {
            // ...
        }
    });
  1.  注册并开启TPNS,在回调函数中获得TPNS Token(XgToken)
    // !!! 上面几步都需要在执行starXG前调用哦
    tpns.startXG((data) => {
        if (!data.errorCode) {
            console.log(`注册成功!`);
            console.log(`TPNS推送用token / xgToken:${data.xgToken}`);
            console.log(`APNS token / deviceToken:${data.deviceToken}`);
            // ...
        }
    })
  1.  注销TPNS
    tpns.stopXG((data) => {
        if (!data.errorCode) {
            console.log(`注销成功!`);
            // ...
        }
    })

API 说明

    /**
     *  注册/注销回调函数的参数类型
     */
    type response = {
        /** 0 为正常, > 0 为报错 **/
        errorCode: number,
        /** 大于0时有错误信息 **/
        errorMsg?: string,
        /** APNS TOKEN **/
        deviceToken?: number,
        /** TPNS TOKEN **/
        xgToken?: number,
    }

    type alertObject = {
        title: string,
        subtitle: string,
        body: string,
        sound: string
    }

    type apsObject = {
        alert: alertObject,
        badge_add_num: number,
        badge_type: number,
        category: string,
        'mutable-content': number,
        sound: string
    }

    type xgObject = {
        bid: number,
        groupId: string,
        guid: number,
        msgid: number,
        msgtype: number,
        pushChannel: number,
        pushTime: number,
        showType: number,
        source: number,
        targettype: number,
        templateId: string,
        tpnsCollapseId: number,
        traceId: string,
        ts: number,
        xgToken: string
    }

    /**
     *  消息、点击消息回调参数类型
     */
    type notification = {
        aps: apsObject,
        xg: xgObject
    }

    /**
     *  域名接口
     */ 
    enum TPNS_DOMAIN {
        GZ_DEFAULT = "tpns.tencent.com",
        HK = "tpns.hk.tencent.com",
        SGP = "tpns.sgp.tencent.com",
        SH = "tpns.sh.tencent.com"
    }

    /**
     *  添加收到通知监听
     */
    function addNotificationListener(onSuccess: (data: notification) => void): void;

    /**
     *  添加点击通知监听
     */
    function addResponseListener(onSuccess: (data: notification) => void): void;

    /**
     *  设置Debug输出(非js-console输出,是Xcode的控制台输出)
     */
    function setEnableDebug(enabled: boolean): void;

    /**
     *  (不推荐,仅测试时使用)在代码中设置accessID,accessKey,设置完成后调用startXG
     */
    function setAccessInfo(accessID: number, accessKey: string): void;

    /**
     *  配置域名接口,不配置默认使用 TPNS_DOMAIN.SH
     *  配置完成后调用startXG
     */ 
    function setConfigHost(host: TPNS_DOMAIN): void;

    /**
     *  注册并开启TPNS
     */
    function startXG(
        onSuccess: (data: response) => void, 
        onError: (data: response) => void
    ): void

    /**
     *  注销TPNS
     */
    function stopXGG(
        onSuccess: (data: response) => void, 
        onError: (data: response) => void
    ): void

    /**
     *  读取TOKEN,需要成功注册开启后使用
     */
    function getToken(onSuccess: (token: string) => void): void;

    /**
     *  设置角标
     */
    function setBadge(value): void;

    function getSdkVersion(onSuccess: (sdkVersion: string) => void): void;

    function clearTPNSCache(): void;

    /**
     *  获取设备通知是否开启
     */
    function deviceNotificationIsAllowed(onSuccess: (isAllowed: boolean) => void): void;

    /**
     *  上传Log日志
     */
    function uploadLogCompletionHandler(
        onSuccess: (data: response) => void, 
        onError: (data: response) => void
    ): void