GithubHelp home page GithubHelp logo

matthijs2704 / vapor-apns Goto Github PK

View Code? Open in Web Editor NEW
341.0 14.0 37.0 191 KB

Simple APNS Library for Vapor (Swift)

License: MIT License

Swift 97.88% Shell 1.81% Lua 0.31%
notifications vapor ios swift swift-3 apns

vapor-apns's Introduction

No longer maintained!

Thanks for checking out my repository! However, it hasn't been updated for a long time and there is a much better (official!) library for interacting with APNS on Vapor.

Check it out here: https://github.com/vapor/apns. It is based on the awesome library of kylebrowning, APNSwift.

===========================================================================================

VaporAPNS

Swift Vapor Crates.io

VaporAPNS is a simple, yet elegant, Swift library that allows you to send Apple Push Notifications using HTTP/2 protocol in Linux & macOS. It has support for the brand-new Token Based Authentication but if you need it, the traditional certificate authentication method is ready for you to use as well. Choose whatever you like!

⭐ License

This project was released under the MIT license.

vapor-apns's People

Contributors

andrewangeta avatar anthonycastelli avatar jimmya avatar loganwright avatar matthijs2704 avatar mono0926 avatar nathanflurry avatar siemensikkema avatar tokorom avatar toto avatar vinnyt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vapor-apns's Issues

Fails to find brew

Im not sure why but,

// MARK: - Homebrew (macOS)
    private func checkBrewInstalled() -> Bool {
        let (_, result) = shell("which", arguments: ["-s", "brew"])
        return result == 0
    }

fails to find my brew,

kylebrowning at Kyles-MacBook-Pro in ~/work/swift/Hello on master [+!?]
$ which brew
/usr/local/bin/brew

Accessing vaporAPNS instance throughout a project

I am currently creating a vaporAPNS instance in main.swift

How can I access this instance in other parts of the Vapor project? Say Routes, Controllers. I am fairly new to Vapor and it is not obvious to me.

Crash without any Information

So, what I've done:

Created a new Amazon EC2 instance, logged into.

sudo apt install curl -> Installed curl without http2 support

run curl -sL swift.vapor.sh/ubuntu | bash to install dependencies (I tried too with Swift 3.0.2)

Installed the toolbox curl -sL toolbox.vapor.sh | bash

Fine, vapor is running.

Then I cloned this sample project

https://github.com/4np/Example-APNS-Client-and-Server

Then I modified the Package.swift with VaporAPNS 1.2.0 to have the curl updater.

cd server

Created the apns.json to have key file and needed entries.

cd into server dir and run vapor clean
after that vapor build --run

Project builded correct, so I tried so send the notification App crash without any information. vapor run is still dead.

curl --version gives me

curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets

without http2

I downloaded the .p8 from the Apple Dev Portal, maybe I have to modify read / write access?

I already tried with chmod ugo+wrx ~/certs/APNsAuthKey_M783BM8HLW.p8 and made sure the key exists.

let fileManager = FileManager.default
if fileManager.fileExists(atPath: APNSAuthKeyPath) {
    log.debug("FILE AVAILABLE")
} else {
    log.debug("FILE NOT AVAILABLE")
}

result

💚 DEBUG main.App():45 - FILE AVAILABLE

I tried few times before to build curl manually that worked, but crash was there too.

Anyone any ideas? I will give up soon :(

Adding another init for Options

It would be nice to have another init for Options that take in the raw/final keys as strings instead of just the path to the .p8 file. I've been having trouble to find the correct path to the .p8 file when my code is pushed up onto Heroku.

crash on Ubuntu 16.04

Ubuntu 16.04

Swift version 3.0.1 (swift-3.0.1-RELEASE)

curl 7.51.1-DEV (x86_64-pc-linux-gnu) libcurl/7.47.0 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets

Here is the code I'm trying to make work:

import VaporAPNS
let options = try! Options(topic: "bundle ID", teamId: "teamID", keyId: "keyID", keyPath: "/whatever/APNsAuthKey.p8")
let vaporAPNS = try VaporAPNS(options: options)

let payload = Payload(title: "Title", body: "Your push message comes here", badge: 1)
payload.sound = "default"

let pushMessage = ApplePushMessage(topic: "bundleID", priority: .immediately, payload: payload, sandbox: true)

vaporAPNS.send(pushMessage, to: ["device UDID"]) { result in
    print(result)
    if case let .success(messageId, deviceToken, serviceStatus) = result, case .success = serviceStatus {
        print ("Success!")
    }
}

It compiles, but crashes on vaporAPNS.send

fatal error: Index out of range
Current stack trace:
0    libswiftCore.so                    0x00007fe5086438e0 swift_reportError + 117
1    libswiftCore.so                    0x00007fe508654e00 _swift_stdlib_reportFatalError + 61
2    libswiftCore.so                    0x00007fe5084608a3 <unavailable> + 0
3    libswiftCore.so                    0x00007fe5085bdffd <unavailable> + 0
4    libswiftCore.so                    0x00007fe5084608a3 <unavailable> + 0
5    libswiftCore.so                    0x00007fe50857f8b0 specialized _fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never + 96
6    libswiftSwiftOnoneSupport.so       0x00007fe508b611f4 <unavailable> + 0
7    App                                0x00000000007dddf6 <unavailable> + 0
8    App                                0x00000000007e10ce <unavailable> + 0
9    App                                0x0000000000425d93 <unavailable> + 0
10   libc.so.6                          0x00007fe50616d740 __libc_start_main + 240
11   App                                0x0000000000424a59 <unavailable> + 0

Memory increasing after each notification

I have notice that the App memory is always increasing ( ~ 1MB in my case ) after each Content Available sent push.

I'm working on a Vapor 1.5.15 project with vaporAPNS 1.2.2

Support Vapor3?

Please please please! As it works on HTTP1 please convert it to Vapor3? Or if you don't want to then maybe I can do that with your permission and will send a pull request?

EXC_BAD_ACCESS and Error message

Hey,

I'm currently developing a small application with vapor-apns and I just ran into an issue which crashed the vapor server with an exc_bad_access.

I'm not entirely sure what happened, but it may be (or not) related to the iOS app which receives the push notification restarting. Here's my setup:

  • I have Vapor sending out push notifications running locally (started in Xcode)
  • I have an iOS app receiving push notifications running on the same wifi as vapor (started in Xcode)
  • Vapor sends out a silent push notification to the iOS app
  • This worked fine during several tests.
  • I restarted the iOS app in Xcode while vapor was still sending push notifications.
  • Vapor-apns logged the following error:
    "error: This error has not been mapped yet in APNSError: Failed initialisation"
  • Vapor crashed in VaporAPNS.swift line 111 with EXC_BAD_ACCESS

Attached is a screenshot of the error environment.

Cheers & Thanks & Keep up the good work!
screen shot 2016-10-11 at 22 30 44

ServiceStatus success

Hi @matthijs2704 ,

there is an issue with the version 2 of this library.

If you send a notification to a non exsiting or bad token, it will return success in the result

vaporAPNS.send(pushMessage, to: deviceTokens) { result in
   if case let .success(_, deviceToken, serviceStatus) = result, case .success = serviceStatus {
        print("💚 success: \(deviceToken) and status \(serviceStatus)")
    }
    else if case let .error(_, deviceToken, error) = result {
        print("❤️ error: \(deviceToken) with \(error)")
    }
    else if case let .networkError(error) = result {
        print("❤️ networkError: \(error)")
    }
}            

so result contains:

▿ Result
  ▿ success : 2 elements
    - apnsId : "some random number"
    - deviceToken : "a valid token, really ;)"
    - serviceStatus : VaporAPNS.ServiceStatus.success


(lldb) po result
▿ Result
  ▿ success : 2 elements
    - apnsId : "some random number"
    - deviceToken : "asdf"
    - serviceStatus : VaporAPNS.ServiceStatus.success

curl automatic updater issue (Ubuntu 16.04)

When running for the first time in a fresh Ubuntu docker container i get the following output:

7.47.0
Your current version of curl is out of date!
VaporAPNS will not work with this version of curl.
You can update curl yourself or we can try to update curl and it's nescessary dependencies.
Continue installing curl? [y/n]
Error: Run failed.

So in my code I set the options.forceCurlInstall = true which should be the equivalent of answering y on the command line to the above. When I build and run again the automatic curl updater does its work and returns:

Installing nghttp2 build dependencies... [Done]
Cloning nghttp2... [Done]
Building nghttp2... [Done]
Installing nghttp2... [Done]
Downloading curl... [Done]
Unpacking curl... [Done]
Building curl... [Done]
Installinstall_curl.sh: 5: install_curl.sh: sudo: not found
Installing curl... [Done]
Cleaning up... [Done]
🚀 Done! Now restart your Vapor project and all should be working!

But when I restart I get this issue:

vapor: /usr/local/lib/libcurl.so.4: no version information available (required by ...)

Which, due to other dependencies in my app, is a problem.

sent successfully, but can't get any push message.Lubuntu 16.04

I am running Lubuntu 16.04 on virtual machine.
I reinstall whole Lubuntu again. I still got the same result.
actually, I reinstalled lubuntu, swift 3.1.1, libcurl4-openssl-dev.
then, i compiled the project. and let the module scanned the version of curl and let it update.
I checked the result. sent successfully, but can't get any push message.

    guard var opt = try? Options(topic: "message.share", certPath: "/home/carl/swift/time/pem/crt.pem", keyPath: "/home/carl/swift/time/pem/key.pem"), let vaporAPNS = try? VaporAPNS(options: opt) else {
        send(error: "APN initalised fail.", code: .unknown, to: response)
        return
    }
    opt.forceCurlInstall = true
    let payload = Payload(message: "Your push message comes here")
    let pushMessage = ApplePushMessage(priority: .energyEfficient, payload: payload, sandbox: true)
    let result = vaporAPNS.send(pushMessage, to: token)
    if case let .success(messageId,deviceToken, serviceStatus) = result, case .success = serviceStatus {
        print ("Success!")
    }

// print "Success!"

content-available

right now, if you set content-available to true all other attributes get ignored.
However, content-available also makes sense for a remote notification to trigger AppDelegates didReceiveRemoteNotification together with a visible notification, not just silent ones.

Update to Vapor 2.0

Since Vapor is updated to 2.0 it would be nice to update Vapor APNS to support Vapor 2.0.
I've checked the dependencies and it seems a lot of the dependencies have already been updated. The only remainder currently is https://github.com/vapor/jwt.git but it seems to be in the process of updating.

Unable to generate Xcode project

As soon as I add your package the vapor xcode -y command just spins forever. This is what my Package.swift file looks like:

// swift-tools-version:4.0
import PackageDescription

let package = Package(
  name: "dts",
  dependencies: [
    .package(url: "https://github.com/vapor/vapor.git", 
             from: "3.0.0-rc.2"),
    .package(url: "https://github.com/vapor/fluent-postgresql.git",
             from: "1.0.0-rc.2"),
    .package(url: "https://github.com/vapor/leaf.git",
             from: "3.0.0-rc.2"),
    .package(url: "https://github.com/matthijs2704/vapor-apns.git",
             from: "2.1.0")
  ],
  targets: [
    .target(name: "App", dependencies: [
                "FluentPostgreSQL", "Vapor", "Leaf"
            ]),
    .target(name: "Run", dependencies: ["App"]),
    .testTarget(name: "AppTests", dependencies: ["App"])
  ]
)

Its not correctly reporting results

No matter when kind of respond im getting from apple server its always success

  • We are completely uploaded and fine
    < HTTP/2 429
    < apns-id: FB0E795C-1FDC-4F4B-A823-E9BD1853EE2D
    <
  • Connection #0 to host api.development.push.apple.com left intact
    VaporAPNS.Result.success(apnsId: "FB0E795C-1FDC-4F4B-A823-E9BD1853EE2D", deviceToken: "85018c74733882e6a36efd32d6e4797fe6ea67476b01f382efd4ab37106c73b1", serviceStatus: VaporAPNS.ServiceStatus.success)
  • Found bundle for host api.development.push.apple.com: 0x102d2be00 [can multiplex]
  • Re-using existing connection! (#0) with host api.development.push.apple.com
  • Connected to api.development.push.apple.com (17.188.165.218) port 443 (#0)
  • Using Stream ID: 11 (easy handle 0x105823a00)

silent remote notification doesn't work

I tried to send silent notification but not lucky enough it doesn't work on me.
I have looked around I saw makeJSON method in Payload class that contentAvailable property that if it is true, then it would be apsPayloadData["content-available"] = true. but as I know, it should be 1.
anyway, even I change to 1, it still doesn't work on me.

Make tests better

More tests, better tests. Make pushing test so that everyone can test it.

build fails on Ubuntu 14.04

I installed curl with http/2 support, and it seems that all fine with it:

Swift version 3.0 (swift-3.0-RELEASE)
Ubuntu 14.04.5

curl 7.46.0 (x86_64-pc-linux-gnu) libcurl/7.46.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 nghttp2/1.17.0-DEV librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp 
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets

vapor build fails:

/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_slist_free_all@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_version@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_easy_setopt@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_multi_cleanup@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_easy_cleanup@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_slist_append@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_multi_add_handle@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_easy_init@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_multi_init@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_multi_setopt@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_multi_assign@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_easy_getinfo@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_multi_socket_action@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_multi_remove_handle@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_global_init@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_multi_info_read@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_easy_pause@CURL_OPENSSL_3'
/whatever/.swiftenv/versions/3.0/usr/lib/swift/linux/libFoundation.so: undefined reference to `curl_version_info@CURL_OPENSSL_3'

error: redefinition of module 'CCurl'

I think I have so module also using 'CCurl', but how can i solve the problem?
thanks.

/swift/usr/bin/swift-build: /usr/local/lib/libcurl.so.4: no version information available (required by /swift/usr/bin/../lib/swift/linux/libFoundation.so)
Compile Swift Module 'time' (8 sources)
/home/carl/swift/time/.build/checkouts/CCurl.git--5837206480670157524/module.modulemap:17:8: error: redefinition of module 'CCurl'
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git-4826581022056867773/module.modulemap:17:8: note: previously defined here
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git--5837206480670157524/module.modulemap:17:8: error: redefinition of module 'CCurl'
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git-4826581022056867773/module.modulemap:17:8: note: previously defined here
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git--5837206480670157524/module.modulemap:17:8: error: redefinition of module 'CCurl'
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git-4826581022056867773/module.modulemap:17:8: note: previously defined here
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git--5837206480670157524/module.modulemap:17:8: error: redefinition of module 'CCurl'
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git-4826581022056867773/module.modulemap:17:8: note: previously defined here
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git--5837206480670157524/module.modulemap:17:8: error: redefinition of module 'CCurl'
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git-4826581022056867773/module.modulemap:17:8: note: previously defined here
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git--5837206480670157524/module.modulemap:17:8: error: redefinition of module 'CCurl'
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git-4826581022056867773/module.modulemap:17:8: note: previously defined here
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git--5837206480670157524/module.modulemap:17:8: error: redefinition of module 'CCurl'
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git-4826581022056867773/module.modulemap:17:8: note: previously defined here
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git--5837206480670157524/module.modulemap:17:8: error: redefinition of module 'CCurl'
module CCurl [system] {
^
/home/carl/swift/time/.build/checkouts/CCurl.git-4826581022056867773/module.modulemap:17:8: note: previously defined here
module CCurl [system] {
^
:0: error: build had 1 command failures
error: exit(1): /swift/usr/bin/swift-build-tool -f /home/carl/swift/time/.build/debug.yaml

Does this work with Vapor 3?

Just wondering if anyone has gotten this to work with Vapor 3? I assume there may be issues with the Packages this repo depends on? Anyone familiar with the library know how much of a lift it would be to migrate to Vapor 3?

Which keypath need to Heroku?

I want to use with Heroku. Which target I need to select to attach APNsAuthKey_AQ34EHZCDQ.p8 file, Run or frozen-sea-xxx or App?

kepernyofoto 2017-10-05 - 15 37 28

kepernyofoto 2017-10-05 - 15 37 19

Which keyPath I need to set be able to use with Heroku?
I attached APNsAuthKey_AQ34EHZCDQ.p8 file finally to the root of frozen-sea-xxx project.

Swift 4 Version

  • Noticed there isn't a swift 4 version right now, is this something that's planned, or can I send a PR for that?

Linker (?) warning

Hi!

Ever since I had VaporAPNS install its fancier version of curl, whenever I run vapor in any way (vapor build, vapor run serve, etc.) I get this message:

vapor: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/lib/swift/linux/libFoundation.so)

Nothing seems to break as a result of this, but the docs didn't mention I should expect it. Any way this can go away? :) Thanks!

cURL HTTP/2 installer doesn't work in Xcode

When I run my project using vapor build --run, the cURL version detection happens normally, and the installer successfully installs the correct version of cURL.
However when I build & run from Xcode, installer works but when I run the app again it still says I have the wrong version of cURL installed, then installs it again. I can't get out of this loop.

What am I missing?

Curl error when using token based auth

let options = try! Options(topic: "com.x.y", teamId: "ABC", keyId: "DEF", keyPath: "/Users/timhadwen/Development/CSIRO/LoraServer/Server/Keys/APNsAuthKey_DEF.p8")
let vaporAPNS = try VaporAPNS(options: options)
let payload = Payload(message: "Test")
let pushMessage = ApplePushMessage(topic: "com.x.y", priority: .immediately, payload: payload, sandbox: true)
let result = vaporAPNS.send(pushMessage, to: l)

Returns the error

networkError(VaporAPNS.SimpleError.string("Failure when receiving data from the peer"))
Looking deeper into the code, giving error 56 in Curl

Run without Vapor

Running swift build with purely vapor-apns yields a bunch of errors around compiling CTLS. (here's what the dependencies in Package.swift look like, in case it isn't clear:

 .Package(url:"https://github.com/matthijs2704/vapor-apns.git", majorVersion: 2, minor: 0)

Adding Vapor, however, compiles successfully.

Is there any way to run this package without vapor, for simple scripting purposes and the like? (possibly adding whatever dependencies of Vapor allow CTLS to compile successfully?)

Crashes on Heroku

Vapor-apns works well for me locally, but I get this when I try to use it on Heroku: "VaporAPNS will not work with this version of curl." Then the app crashes.

Curl +nghttp2 not detected

I've just added VaporAPNS to my project. After the warning that my curl version lacked HTTP2, I follow the steps as layed out here in order to have a curl version with HTTP2 on my system.
I expected this to resolve the issue, but VaporAPNS is still complaining with the same message (Your current version of curl lacks HTTP2!).
Curiously, if I tell it to install HTTP2, it also says It doesn't look like you have Homebrew installed! which is not true :). Is it perhaps looking in the wrong place? Do I maybe need additional linker flags to tell it where to look?

Running on macOS 10.12.4.

APNs response 'TooManyProviderTokenUpdates'

I know this might not seem like an issue with vaporAPNS but I'm feeling as though it could be.

The other day I was testing push notifications locally on my Mac and I started getting status: '429', response: 'TooManyProviderTokenUpdates' back from APNs. I wasn't really sure what this response actually meant but I found out that it basically means one notification is being sent multiple times to the same device token. https://forums.developer.apple.com/thread/86288?q=toomany

I checked my code and verified that I was not accidentally doing this. I noticed that it happens when a particular event in my app triggers two notification to be sent; 1 notification to user A and 1 to user B.
Generally the first notification to be sent (to user A) succeeds. The second notification always fails.

So I did a test where I reinitialized vaporAPNS after sending the first notification but before sending the second one.
// send notification to user A
vaporAPNS = try VaporAPNS(options: options)
// send notification to user B

This solved the problem and both notifications were continuously being successfully delivered.

Could it be possible that some state is not being properly cleared and transferring between the successive curl operations in the send func?

[Feature] configure Certs and Keys from env vars

Hi...

Have you thought about adding support for configuring certificates or auth key from environment variables? I mean putting the contents of the files in the environment variable, this way it could work on services with ephemeral storage like heroku

Build failing on Heroku

Hello,

I've spent almost a day trying to fix my build on Heroku after introducing vapor-apns. Locally, it worked great, but when I tried to push to the Heroku repository, I always got the following build error:

Linking ./.build/release/App
/tmp/build_6ea42bc7d7da2139e7c3f372f2fdc6c9/.build/release/VaporAPNS.build/VaporAPNS.swift.o:/tmp/build_6ea42bc7d7da2139e7c3f372f2fdc6c9/.build/release/VaporAPNS.build/ApplePushMessage.swift.o:function _TTSf4g_gs_n___TFC9VaporAPNS9VaporAPNS4sendfTVS_16ApplePushMessage2toSS_OS_6Result: error: undefined reference to '_TFE8VaporJWTPS_19SignatureVerifiable19verifySignatureWithfzPS_6Signer_Sb'
clang-3.7: error: linker command failed with exit code 1 (use -v to see invocation)
:0: error: link command failed with exit code 1 (use -v to see invocation)
:0: error: build had 1 command failures
swift-build: error: exit(1): /app/.swiftenv/versions/3.0/usr/bin/swift-build-tool -f /tmp/build_6ea42bc7d7da2139e7c3f372f2fdc6c9/.build/release.yaml

I've tried to isolate the problem and got to the point of initializing a Vapor project from their default template and adding:
.Package(url: "https://github.com/matthijs2704/vapor-apns.git", majorVersion: 1, minor: 1)
to the Package.swift file. I didn't add any code to the template.

As I investigated, this will maybe be fixed by making a new release which would include the latest 3 commits (so far), they seem to be related.

Thanks in advance,
Jovan

Vapor 2.0

Will it be compatible with new Vapor 2.0~ ?

Async?

Maybe add an sync and async way of sending push notifications using GCD. So the end-developer can just pass the payload and not worry about the lag it causes on the server.

Now the end-developer can do that himself of course

Crash on heroku

This library doesn't work on Heroku it crashes the server I tried much, even doesn't give error.

             ```
                log.debug("FILE AVAILABLE")
                let options = try! Options(topic: "radar.com.Radar", teamId: "S6M3DL7MYG", keyId: "K73428556X", keyPath: drop.config["servers", "default", "KeyURL"]?.string ?? "default")
                log.debug("Option SET")
                let vaporAPNS = try VaporAPNS(options: options)
                log.debug("APNS CREATED")

                let payload = Payload(message: "Your push message comes here")
                log.debug("PAYLOAD CREATED")

                let pushMessage = ApplePushMessage(topic: "radar.com.Radar", priority: .immediately, payload: payload, sandbox: false)
                log.debug("READY TO SEND")

                let result = vaporAPNS.send(pushMessage, to: "33ee125d63a0b2aeedd42bae4f6dc61a588a96e312ca8ec3ed44be15e34ee60e")
                log.debug("SENT") 

Key not found

Let me know how to include key file.

fatal error: 'try!' expression unexpectedly raised an error: Key file could not be found on your disk. Double check if the file exists and if the path is correct: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.63/src/swift/stdlib/public/core/ErrorType.swift, line 178

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.