# cordova-plugin-push-master

> push for ionic

Latest version **1.1.2** (published 2020-08-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install cordova-plugin-push-master
pnpm add cordova-plugin-push-master
yarn add cordova-plugin-push-master
bun add cordova-plugin-push-master
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2020-08-24 |
| First published | 2018-08-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | thomas_pan |
| Maintainers | thomas_pan |
| Keywords | ecosystem:cordova |

## Links

- npm: https://www.npmjs.com/package/cordova-plugin-push-master
- Repository: https://github.com/pysGitHub/PushPlugin
- Homepage: https://github.com/pysGitHub/PushPlugin#readme
- Issues: https://github.com/pysGitHub/PushPlugin/issues
- npm.io page: https://npm.io/package/cordova-plugin-push-master

## Recent versions

- 1.1.2 (latest) — 2020-08-24
- 1.1.1 — 2020-08-21
- 1.0.8 — 2020-05-22
- 1.0.7 — 2018-09-17
- 1.0.6 — 2018-09-11
- 1.0.5 — 2018-09-07
- 1.0.4 — 2018-09-03
- 1.0.3 — 2018-08-31
- 1.0.2 — 2018-08-22

## README

# PushPlugin
push for ionic
使用方法：
1.在自己的项目中使用ionic cordova plugin add cordova-plugin-push-master加载插件
2.在想要注册推送的.ts文件中添加以下操作：
① 在import和@Component添加 declare let cordova: any;
② 实现下面的方法



     if (platform.versions().ios) {
          // 拿token
          cordova.plugins.PushPlugin.initPushMethod(
            "ios",
            message => {
              // alert("deviceToken = "+message)
              // 存储接收到的deviceToken
              //this.storage.set('deviceToken',message);
              global.deviceToken = message;
              global.pushServerID = "1";
              let pushServerID = "1";
              this.events.publish("data:data", message, pushServerID);
              // 存储pushServerID
              //this.storage.set('pushServeID','1');
              this.rootPage = "LoginPage";
            },
            error => {
              this.rootPage = "LoginPage";
            }
          );
        } else {
          cordova.plugins.PushPlugin.getPushToken(
            "android",
            message => {
              let deviceTokenMessage: string = message;
              let pushServerID = deviceTokenMessage.substr(
                deviceTokenMessage.length - 1,
                1
              );
              let deviceToken = deviceTokenMessage.substr(
                0,
                deviceTokenMessage.length - 1
              );
              // 存储pushServerID
              global.deviceToken = deviceToken;
              global.pushServerID = pushServerID;
              this.rootPage = "LoginPage";
            },
            error => {
              this.rootPage = "LoginPage";
            }
          );
        }
        
      // 拿推送消息
      cordova.plugins.PushPlugin.receivePushUrl("common",(message)=> {
        alert("urlStr = "+message)
      },
      (error)=> {
        // alert(error)
      });
      
 3.在ios平台中添加下列代码
 ① 在AppDelegte.h声明下列属性：
           
           @property (nonatomic,strong)NSDictionary * launchOptionDic;
            
            
            
 ② 在AppDelegate.m的入口类添加下列代码：
        
        if(launchOptions){
         self.launchOptionDic = launchOptions;
         }

---
_Source: https://npm.io/package/cordova-plugin-push-master · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
