This repository has been archived by the owner on Jun 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9a3a0d
commit c37aab0
Showing
3 changed files
with
83 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// PayloadContent.swift | ||
// APNS | ||
// | ||
// Created by Anthony Castelli on 4/6/18. | ||
// | ||
|
||
import Foundation | ||
import Vapor | ||
|
||
struct Alert: Content { | ||
enum CodingKeys: String, CodingKey { | ||
case title = "title" | ||
case subtitle = "subtitle" | ||
case body = "body" | ||
|
||
case titleLocKey = "title-loc-key" | ||
case titleLocArgs = "title-loc-args" | ||
|
||
case actionLocKey = "action-loc-key" | ||
|
||
case bodyLocKey = "body-loc-key" | ||
case bodyLocArgs = "body-loc-args" | ||
|
||
case launchImage = "launch-image" | ||
} | ||
var title: String? | ||
var subtitle: String? | ||
var body: String? | ||
var titleLocKey: String? | ||
var titleLocArgs: [String]? | ||
var actionLocKey: String? | ||
var bodyLocKey: String? | ||
var bodyLocArgs: [String]? | ||
var launchImage: String? | ||
} | ||
|
||
struct APS: Content { | ||
var alert: Alert | ||
var badge: Int? | ||
var sound: String? | ||
var category: String? | ||
var contentAvailable: Bool = false | ||
var hasMutableContent: Bool = false | ||
} | ||
|
||
struct PayloadContent: Content { | ||
var aps: APS | ||
var threadId: String? | ||
var extra: [String : String] = [:] | ||
|
||
init(payload: Payload) { | ||
let alert = Alert( | ||
title: payload.title, | ||
subtitle: payload.subtitle, | ||
body: payload.body, | ||
titleLocKey: payload.titleLocKey, | ||
titleLocArgs: payload.titleLocArgs, | ||
actionLocKey: payload.actionLocKey, | ||
bodyLocKey: payload.bodyLocKey, | ||
bodyLocArgs: payload.bodyLocArgs, | ||
launchImage: payload.launchImage | ||
) | ||
self.aps = APS( | ||
alert: alert, | ||
badge: payload.badge, | ||
sound: payload.sound, | ||
category: payload.category, | ||
contentAvailable: payload.contentAvailable, | ||
hasMutableContent: payload.hasMutableContent | ||
) | ||
self.threadId = payload.threadId | ||
self.extra = payload.extra | ||
} | ||
} |