{"id":19326263,"url":"https://github.com/comsince/ups_meizu_pushsdk","last_synced_at":"2026-03-07T09:31:29.804Z","repository":{"id":69377560,"uuid":"114836590","full_name":"comsince/ups_meizu_pushsdk","owner":"comsince","description":"基于魅族统一推送平台构建的,采用Netty pipline职责链的思想统一PushSDK接入，方便后续接入其他厂商，旨在实现魅族，小米，华为等PushSDK的统一接入","archived":false,"fork":false,"pushed_at":"2017-12-20T09:08:52.000Z","size":1183,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-29T06:07:57.686Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://comsince.github.io/2017/10/26/ups-pushsdk/","language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/comsince.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-20T03:03:56.000Z","updated_at":"2023-12-04T01:41:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"0737755f-22c8-4482-a524-21a2a4737e8c","html_url":"https://github.com/comsince/ups_meizu_pushsdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/comsince/ups_meizu_pushsdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comsince%2Fups_meizu_pushsdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comsince%2Fups_meizu_pushsdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comsince%2Fups_meizu_pushsdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comsince%2Fups_meizu_pushsdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/comsince","download_url":"https://codeload.github.com/comsince/ups_meizu_pushsdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comsince%2Fups_meizu_pushsdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30210832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T02:12:56.002Z","updated_at":"2026-03-07T09:31:29.773Z","avatar_url":"https://github.com/comsince.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 集成推送平台PushSDK设计文档\n\n[![Build Status][travis-image]][travis] [![License][license-image]][license] [![Release][release-image]][releases] [![Javadoc][java-doc-image]][java-doc]\n\n此文档在于向开发者介绍魅族统一推送平台PushSDK如何对各个厂家的PushSDK进行整合以及我们在统一接口设计中遵循的规则，由于各个厂家的API接口\n功能差异巨大我们只对各个厂商共用的接口进行统一封装，当然你也可以直接使用厂商提供的接口。UpsPushSDK设计初衷不仅仅是在帮助开发者接入魅族的统一推送\n平台，也希望我们能够尽量简化接口的同时，能够将厂商所有的个性化接口全部提供给开发者，即使开发者不使用魅族统一推送平台也能通过各个厂商提供\n推送服务平台快速接入。\n\n## 背景\n目前各个主流厂商为了优化手机耗电情况,实行静默后台策略,导致很多应用无法常驻后台,导致基于长连接的推送应用也无法常驻后台\n进而影响推送消息的到达率,因此各个主流厂商(小米,华为,魅族)都提供基于系统推送服务的方案,应用需要接入各个厂商的PushSDK\n才能在各个平台的手机上接收推送消息.此项目为了屏蔽不同厂商PushSDK的接入流程,为开发这提供统一的接口,方便开发者一次集成\n 即可完成不同厂商的PushSDK的接入.\n\n## 一 接入说明 \n\n* [快速接入文档详见](QuickStart.md)\n* [统一推送平台的规则说明](UpsIntegrateReadme.md)\n \n## 二 接口说明\n\n为了统一接入方式,ups-meizu-pushsdk沿用魅族pushSDK的接口的定义方式,其主要包括UpsPushManager功能入口类和接收消息\n回调的广播回调类UpsPushReceiver.\n\n### 2.1 UpsPushManager 接入类\n\n| 接口名称      | 接口说明| 使用建议|是否已经废弃|对应UpsPushReceiver回调方法|\n| :--------: | :--------:| :--: |:--: |:--: |\n|register(Context context,String appId,String appKey)|订阅接口|建议Application onCreate调用|否|onUpsCommandResult(Context context, UpsCommandMessage upsCommandMessage)|\n|unRegister(Context context)|反订阅接口|取消所有推送时使用,慎用,如果取消,将有可能停止所有推送|否|onUpsCommandResult(Context context, UpsCommandMessage upsCommandMessage)|\n|setAlias(Context context,String alias)|订阅别名|无|否|onUpsCommandResult(Context context, UpsCommandMessage upsCommandMessage)|\n|unSetAlias(Context context,String alias)|取消别名|无|否|onUpsCommandResult(Context context, UpsCommandMessage upsCommandMessage)|\n\n### 2.2 UpsPushMessageReceiver 广播接收器 \n\nUpsPushMessageReceiver是一个抽象的BroadcastReceiver类，为了统一各个厂商的回调，必须定义通用的方法，在包装数据格式时只是原样返回，不做任何修饰，\n里面定义了五个方法，分别为`onThroughMessage`,`onNotificationClicked`,`onNotificationArrived`,`onNotificationDeleted`,`onUpsCommandResult`\n \n \n| 接口名称      | 接口说明| 使用建议|是否已经废弃|\n| :--------: | :--------:| :--: |:--: |\n|onThroughMessage(Context context,UpsPushMessage upsPushMessage)| 透传消息回调|无|否|                                                                                  \n|onNotificationClicked(Context context, UpsPushMessage upsPushMessage)|通知栏点击回调|无|否|\n|onNotificationArrived(Context context, UpsPushMessage upsPushMessage)|通知栏展示回调|小米，魅族尽在应用进程在时回调，华为不回调|否|\n|onNotificationDeleted(Context context, UpsPushMessage upsPushMessage)|通知栏删除回调|仅仅Flyme基于android6.0以下版本会回调，小米华为均不支持|否|\n|onUpsCommandResult(Context context, UpsCommandMessage upsCommandMessage)||无|否|\n\n\n##  三 UPSManager API 详细说明\n\n### 3.1 public static void register(Context context,String appId,String appKey)\n\n注册统一推送服务，建议在应用启动时调用\n\n| 参数列表      | 参数说明| \n| :--------: | :--------:| \n|context| Android平台上app的上下文，建议传入当前app的application context|                                                                                \n|appId|应用在统一集成平台申请的appid|\n|appKey|应用在统一集成平台申请的appKey|\n\n### 3.2 public static void unRegister(Context context)\n\n反订阅推送服务,关闭推送时使用\n\n| 参数列表      | 参数说明| \n| :--------: | :--------:| \n|context| Android平台上app的上下文，建议传入当前app的application context|                                                                                \n\n### 3.3 public static void setAlias(Context context,String alias)\n\n| 参数列表      | 参数说明| \n| :--------: | :--------:| \n|context| Android平台上app的上下文，建议传入当前app的application context|                                                                                \n|alias|应用别名|\n\n### 3.4 public static void unSetAlias(Context context,String alias)\n\n| 参数列表      | 参数说明| \n| :--------: | :--------:| \n|context| Android平台上app的上下文，建议传入当前app的application context|                                                                                \n|alias|应用别名|\n\n\n## 四 UpsPushMessageReceiver 回调方法详细说明\n\n### 4.1 public void onThroughMessage(Context context,UpsPushMessage upsPushMessage)\n\n接收透传消息回调\n\n**NOTE:** 参数说明\n\n| 参数列表      | 参数说明| \n| :--------: | :--------:| \n|context| Android平台上app的上下文，建议传入当前app的application context|                                                                                \n|upsPushMessage|服务端返回的结果全部封装在upsPushMessage对象中，可以从对象中和获取例如`content` `title` `extra` `pushType` `company`|\n\n**NOTE:** UpsPushMessage 参数说明\n在设计UpsPushMessage时我们尽量保证将厂商提供的参数信息回调给用户，方便开发者能够使用各个厂商的个性化功能\n\n| 参数名      | 参数说明| \n| :--------: | :--------:| \n|title|消息的标题，如果时通知栏消息，则为通知栏标题|\n|content|消息内容,如果时通知栏则为消息通知栏内容，如果为透传消息，则为透传消息体|\n|pushType|消息类型,0代表通知栏消息，1代表透传消息|\n|company|厂商类型包括：UpsPushMessage.MEIZU,UpsPushMessage.HUAWEI,UpsPushMessage.XIAOMI|\n|extra|代表各个平台的传递的对象，魅族代表selfDefineContentString，小米代表MiPushMessage，华为代表bundle,需要通过判断company进行对象类型转化，如下：|\n\n```\n    if(company==UpsPushMessage.MEIZU){ \n        string extra = extra;\n    } else if(company==UpsPushMessage.XIAOMI){\n        MiPushMessage miPushMssage = (MiPushMessage)extra;\n    } else if(company==UpsPushMessage.HUAWEI){\n        Bundle bundle = (Bundle)extra;\n    }\n```\n\n### 4.2 public void onNotificationClicked(Context context, UpsPushMessage upsPushMessage)\n\n接收通知栏消息点击回调\n\n| 参数列表      | 参数说明| \n| :--------: | :--------:| \n|context| Android平台上app的上下文，建议传入当前app的application context|                                                                                \n|upsPushMessage|服务端返回的结果全部封装在upsPushMessage对象中，可以从对象中和获取例如`content` `title` `extra` `pushType` `company`|\n\n**NOTE:** UpsPushMessage 参数说明\n在设计UpsPushMessage时我们尽量保证将厂商提供的参数信息回调给用户，方便开发者能够使用各个厂商的个性化功能\n\n| 参数名      | 参数说明| \n| :--------: | :--------:| \n|title|消息的标题，如果时通知栏消息，则为通知栏标题|\n|content|消息内容,如果时通知栏则为消息通知栏内容，如果为透传消息，则为透传消息体|\n|pushType|消息类型,0代表通知栏消息，1代表透传消息|\n|notifyId|通知栏消息Id|\n|company|厂商类型包括：UpsPushMessage.MEIZU,UpsPushMessage.HUAWEI,UpsPushMessage.XIAOMI|\n|extra|代表各个平台的传递的对象，魅族代表selfDefineContentString，小米代表MiPushMessage，华为代表bundle,需要通过判断company进行对象类型转化，如下：|\n\n```\n    if(company==UpsPushMessage.MEIZU){ \n        string extra = extra;\n    } else if(company==UpsPushMessage.XIAOMI){\n        MiPushMessage miPushMssage = (MiPushMessage)extra;\n    } else if(company==UpsPushMessage.HUAWEI){\n        Bundle bundle = (Bundle)extra;\n    }\n```\n### 4.3 public void onNotificationArrived(Context context, UpsPushMessage upsPushMessage)\n\n接收通知栏消息到达回调\n\n| 参数列表      | 参数说明| \n| :--------: | :--------:| \n|context| Android平台上app的上下文，建议传入当前app的application context|                                                                                \n|upsPushMessage|服务端返回的结果全部封装在upsPushMessage对象中，可以从对象中和获取例如`content` `title` `extra` `pushType` `company`|\n\n**NOTE:** UpsPushMessage 参数说明\n在设计UpsPushMessage时我们尽量保证将厂商提供的参数信息回调给用户，方便开发者能够使用各个厂商的个性化功能\n\n| 参数名      | 参数说明| \n| :--------: | :--------:| \n|title|消息的标题，如果时通知栏消息，则为通知栏标题|\n|content|消息内容,如果时通知栏则为消息通知栏内容，如果为透传消息，则为透传消息体|\n|pushType|消息类型,0代表通知栏消息，1代表透传消息|\n|notifyId|通知栏消息Id|\n|company|厂商类型包括：UpsPushMessage.MEIZU,UpsPushMessage.HUAWEI,UpsPushMessage.XIAOMI|\n|extra|代表各个平台的传递的对象，魅族代表selfDefineContentString，小米代表MiPushMessage，华为代表bundle,需要通过判断company进行对象类型转化，如下：|\n\n```\n    if(company==UpsPushMessage.MEIZU){ \n        string extra = extra;\n    } else if(company==UpsPushMessage.XIAOMI){\n        MiPushMessage miPushMssage = (MiPushMessage)extra;\n    } else if(company==UpsPushMessage.HUAWEI){\n        Bundle bundle = (Bundle)extra;\n    }\n```\n\n### 4.4 public void onNotificationDeleted(Context context, UpsPushMessage upsPushMessage)\n\n接收通知栏消息删除回调\n\n| 参数列表      | 参数说明| \n| :--------: | :--------:| \n|context| Android平台上app的上下文，建议传入当前app的application context|                                                                                \n|upsPushMessage|服务端返回的结果全部封装在upsPushMessage对象中，可以从对象中和获取例如`content` `title` `extra` `pushType` `company`|\n\n**NOTE:** UpsPushMessage 参数说明\n在设计UpsPushMessage时我们尽量保证将厂商提供的参数信息回调给用户，方便开发者能够使用各个厂商的个性化功能\n\n| 参数名      | 参数说明| \n| :--------: | :--------:| \n|title|消息的标题，如果时通知栏消息，则为通知栏标题|\n|content|消息内容,如果时通知栏则为消息通知栏内容，如果为透传消息，则为透传消息体|\n|pushType|消息类型,0代表通知栏消息，1代表透传消息|\n|notifyId|通知栏消息Id|\n|company|厂商类型包括：UpsPushMessage.MEIZU,UpsPushMessage.HUAWEI,UpsPushMessage.XIAOMI|\n|extra|代表各个平台的传递的对象，魅族代表selfDefineContentString，小米代表MiPushMessage，华为代表bundle,需要通过判断company进行对象类型转化，如下：|\n\n```\n    if(company==UpsPushMessage.MEIZU){ \n        string extra = extra;\n    } else if(company==UpsPushMessage.XIAOMI){\n        MiPushMessage miPushMssage = (MiPushMessage)extra;\n    } else if(company==UpsPushMessage.HUAWEI){\n        Bundle bundle = (Bundle)extra;\n    }\n```\n\n### 4.5 public void onUpsCommandResult(Context context, UpsCommandMessage upsCommandMessage)\n\n接收订阅，反订阅，别名订阅，取消别名订阅回调\n\n\n| 参数列表      | 参数说明| \n| :--------: | :--------:| \n|context| Android平台上app的上下文，建议传入当前app的application context|                                                                                \n|upsCommandMessage|服务端返回的结果全部封装在upsCommandMessage对象中，可以从对象中和获取例如code,message,commandType,commandResult|\n\n**NOTE:** UpsCommandMessage具体参数说明\n \n | 参数名      | 参数说明| \n | :--------: | :--------:| \n |code|表示订阅，反订阅的返回码,如果成功，即返回UPS.SUCCESS==200,否则返回错误状态码|\n |message|表示执行请求返回的成功与错误信息|\n |commandType|表示请求服务类型,目前包括四种UpsManager.REGISTER,UpsManager.UNREGISTER,UpsManager.SUBALIAS,UpsManager.UNSUBALIAS|\n |commandResult|表示执行成功后，服务端返回的结果参数，例如订阅成功后，返回的pushId.|\n |company|厂商类型包括：UpsPushMessage.MEIZU,UpsPushMessage.HUAWEI,UpsPushMessage.XIAOMI|\n |extra|代表各个平台传递对象，魅族为空，小米为MiPushCommandMessage，华为为Bundle，需要通过company进行类型转换如下代码：|\n \n ```\n if(company==UpsPushMessage.MEIZU){ \n         string extra = extra;\n     } else if(company==UpsPushMessage.XIAOMI){\n         MiPushCommandMessage miPushCommandMessage = (MiPushCommandMessage)extra;\n     } else if(company==UpsPushMessage.HUAWEI){\n         Bundle bundle = (Bundle)extra;\n     }\n ```\n\n\n## 五 技术实现\n \n### 5.1 UpsManager 接口代理\n \n UpsManager调用的定义的API最终会调用各个厂商提供的API,我们展示屏蔽了具体进行厂商判断的细节，以及对接魅族统一推送平台的接口。\n 以下为订阅逻辑的逻辑图:\n \n![image](attach/ups_meizu_pushsdk_register.png)\n \n 具体步骤基本和厂商sdk的逻辑一致，只是增加了上报魅族统一推送平台订阅状态的逻辑，该逻辑我们可以考虑是否支持上报，即使此步骤执行不成功，UpsReceiver也会回调\n 各个厂商的状态，完全不必担心此逻辑会影响厂商的具体的订阅发起与回调逻辑。\n \n **NOTE:** 以上步骤值讨论了订阅的逻辑，其他如别名订阅与此大致一致。\n \n \n## License\n\n```\n /*\n  * MIT License\n  *\n  * Copyright (c) [2017] [Meizu.inc]\n  *\n  * Permission is hereby granted, free of charge, to any person obtaining a copy\n  * of this software and associated documentation files (the \"Software\"), to deal\n  * in the Software without restriction, including without limitation the rights\n  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n  * copies of the Software, and to permit persons to whom the Software is\n  * furnished to do so, subject to the following conditions:\n  *\n  * The above copyright notice and this permission notice shall be included in all\n  * copies or substantial portions of the Software.\n  *\n  * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n  * SOFTWARE.\n  */\n ```\n \n [license-image]: https://img.shields.io/badge/License-MIT-yellow.svg\n [license]: https://opensource.org/licenses/MIT\n \n [release-image]: http://img.shields.io/badge/release-1.0.4-blue.svg?style=flat\n [releases]: https://bintray.com/meizupush/PushSDK/ups_meizu_pushsdk\n \n [coveralls-image]: https://www.travis-ci.org/comsince/ups_meizu_pushsdk.svg?branch=master\n [coveralls]: https://coveralls.io/github/comsince/snowplow-android-tracker?branch=master\n \n [travis]: https://www.travis-ci.org/comsince/ups_meizu_pushsdk\n [travis-image]: https://www.travis-ci.org/comsince/ups_meizu_pushsdk.svg?branch=master\n \n [java-doc-image]: https://img.shields.io/badge/javadoc-release-brightgreen.svg\n [java-doc]: https://comsince.github.io/ups_meizu_pushsdk/index.html","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomsince%2Fups_meizu_pushsdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomsince%2Fups_meizu_pushsdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomsince%2Fups_meizu_pushsdk/lists"}