Giter Site home page Giter Site logo

hdjgpushtool-vapor's Introduction

VAPOR - HDJGPushTool

JiGuang Push is an independent third-party cloud push platform in China, which can quickly integrate the message push function of Android and iOS platforms. There may not be many users in other countries. If you need English instructions, you can submit an issue.

vapor是一个swift语言开发的服务器框架,该项目是在vapor框架下集成使用极光推送的库。

使用swift语言开发,基于极光推送官网的Rest Api接口,三行代码即可快速集成服务器端功能。

一、项目集成

可以采用SPM方式添加,也可以采用源文件方式添加

vapor 3.0版本集成SPM方式集成

Vapor项目的Package文件中,在dependencies添加依赖

.package(url: "https://github.com/DamonHu/HDJGPushTool-Vapor.git", from: "1.0.0"),

targets中添加

.target(name: "App", dependencies: ["Vapor", "HDJGPushTool"]),

vapor 4.0版本集成SPM方式集成

Vapor项目的Package文件中,在dependencies添加依赖

.package(url: "https://github.com/DamonHu/HDJGPushTool-Vapor.git", from: "4.0.0"),

targets中添加

.target(name: "App", dependencies: [
            .product(name: "HDJGPushTool", package: "HDJGPushTool-Vapor"),
        ]),

1.2、源文件方式添加

将本git仓库里面的Sources目录下的HDJGPushTool整个文件夹拖入添加到工程即可

二、快速使用

//1、导入通知类
import HDJGPushTool
//2、创建通知对象, 记得把JiguangAppkey和JiguangSecret替换为你自己应用的appkey和secret
let pushTool = HDJGPushTool(appKey: JiguangAppkey, appSecrect: JiguangSecret)
//3、创建通知内容
let pushModel = HDJGPushModel(alertTitle: "通知的标题", alertContent: "通知的内容")
//4、发送通知
try pushTool.pushNotification(req, pushModel: pushModel)

示例:

router.post("notice/callback", String.parameter) { (req) -> String in
        let webName = try req.parameters.next(String.self)
        //发送通知
        let pushTool = HDJGPushTool(appKey: Lazypig_jiguangAppkey, appSecrect: Lazypig_jiguangSecret)
        let pushModel = HDJGPushModel(alertTitle: "网站回调了", alertContent: "有网站请求回调")
        try pushTool.pushNotification(req, pushModel: pushModel)
        return "回调成功"
}

三、更多配置

可以通过设置pushModel实现更多操作,推送的目标,可以参考极光的文档设置: 极光推送官方文档

let pushModel = HDJGPushModel(alertTitle: "通知的标题", alertContent: "通知的内容")
//推送到测试环境
pushModel.apnsProduction = fasle
//单独推送的平台
pushModel.platform = .ios
//推送的目标,可通过registrationId、tag、tagAnd、tagNot、alias等创建audience设置专门的推送目标,如果设置为null则为推送给全部用户
pushModel.audience = HDJGPushAudienceModel(registrationId: AdminPushList)

直接使用极光的api会更灵活,你可以进行参考或者扩充以便更加方便使用

hdjgpushtool-vapor's People

Contributors

damonhu avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.