coccodrillo / apns Goto Github PK
View Code? Open in Web Editor NEWA Golang package for sending Apple Push Notifications and using the Feedback Service.
License: MIT License
A Golang package for sending Apple Push Notifications and using the Feedback Service.
License: MIT License
The following link:
In README.md
is broken.
I think that the right URL is now https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Appendixes/BinaryProviderAPI.html#//apple_ref/doc/uid/TP40008194-CH106-SW5
Hi,
i can't set badge '+1' on payload. My app can't increase counter.
Can you change type of badge payload like string?
How to set a certificate pass phrase? Any example implementation with pass phrase?
When I ran the sample code, I get the following error message:
Alert: {"aps":{"alert":"Hello, world!","badge":42,"sound":"bingbong.aiff"}}
Success: false
Error: EOF
I'm wondering how I can get more information about the error. Thanks.
The code segment:
responseChannel := make(chan []byte, 1)
go func() {
buffer := make([]byte, 6, 6)
connection.socket.Read(buffer)
responseChannel <- buffer
}()
I meet a problem:could not get the status code, so i printed the buffer, and the output like this:" [165 63 42 60 125 22]". the output is different for each time. And the apple document say that the first byte is "8". Is there something wrong on it? I could not understand, coult you help me resolve this problem?
ps:I meet this problem when it push with a invaliable token. And it push successfully for current token.
Hello sir ..
I used your library to push notification to ios devices but I get that error :
Error: encoding/hex: odd length hex string
this is my code which I got from your documentation example
package main
import (
"fmt"
apns "github.com/anachronistic/apns"
)
func main() {
payload := apns.NewPayload()
payload.Alert = "Hello, world!"
payload.Badge = 42
payload.Sound = "default"
pn := apns.NewPushNotification()
pn.DeviceToken = "84678103 de0bda6d df26349a d2cda004 0bfe951d c0a9e993 022406e8 0f161c78"
pn.AddPayload(payload)
client := apns.NewClient("gateway.sandbox.push.apple.com:2195", "pushcahrtcert.pem", "pushchatkey.pem")
resp := client.Send(pn)
alert, _ := pn.PayloadString()
fmt.Println(" Alert:", alert)
fmt.Println("Success:", resp.Success)
fmt.Println(" Error:", resp.Error)
}
Can you please clarify what license this project is released under?
Is it currently possible to not send a value for badge count? It seems to be the badge count is always sent since when it isn't explicitly set to something the library sets it to -1. I realize the issue here is differentiating between an empty badge count and a badge count set to zero. Two possible solutions would be to either make badge count an int pointer or create a method/flag on the payload that signals that the user wants to exclude the badge count. Thoughts?
I have new issue which says :
Error: crypto/tls: failed to parse private key
I tried to use
client := apns.NewClient("gateway.sandbox.push.apple.com:2195", "/home/user/go/pushios/pushcahrtcert.pem", "/home/user/go/pushios/pushchatkey.pem")
and
client := apns.NewClient("gateway.sandbox.push.apple.com:2195", "pushcahrtcert.pem", "pushchatkey.pem")
but I get the same issue
With the coming of iOS 8, the max payload size is now 2kb, rather than 256 bytes. This change though is also backwards compatible to devices running older versions of the OS. This needs to be adjusted in this library, and I can likely submit a quick PR for this soon.
As of iOS 8, the APNs server can send category
in the payload, for use when the app sets up interaction with receipt of the notification. All that really needs to be done is add that just as the ContentAvailable
flag was added. If I have some time in the next few days I can likely submit a PR for this functionality.
Hi there,
Trying to use this library against the production APNS servers results in the above error (Go 1.4, OSX Yosemite). Digging into it, this appears to be a possibly overly-aggressive check by crypto/tls
for IP addresses in the server certificate. openssl s_client
works fine with the same inputs.
I'm not sure what the solution is, but a hack to work around it is to enable InsecureSkipVerify
. Needless to say, this is not ideal.
Have you (or anyone else) seen this?
Alec
x
Is there any way for me to pass the Entrust CA root certificate?
Please accept pull request by mutable-content
The code in client.go says:
select {
case r := <-responseChannel:
resp.Success = false
resp.AppleResponse = ApplePushResponses[r[1]]
err = errors.New(resp.AppleResponse)
case <-timeoutChannel:
resp.Success = true
}
Does this set Success
to true
when the client times out?
I'm getting resp.Success
= false
and err
= NO_ERRORS
. I'm not sure how to interpret the results.
I don't have the bandwidth to keep up with Apple life these days, so I'd like to pass this to someone else to maintain. Otherwise I'll drop an "unmaintained" badge on the README so the status is clear.
According to Apple Docs, they want you to send as many push notifications using the one connection. The documentation states that you can actually send the data to each push notification next to each other instead one at a time.
In fact the docs state that if you send many push notifications separately, it may interpret it as a DoS attack.
Is there any way to do this using your package?
tls handshake error EOF
ConnectAndWrite error
Alert: {"aps":{"alert":"Hello, world!","badge":42,"sound":"bingbong.aiff"}}
Success: false
Error: EOF
package main
import (
"fmt"
apns "github.com/anachronistic/apns"
)
func main() {
payload := apns.NewPayload()
payload.Alert = "Hello, world!"
payload.Badge = 42
payload.Sound = "bingbong.aiff"
pn := apns.NewPushNotification()
pn.DeviceToken = "de75f5c081a85b28f62ccb59153581fcade5cc73d8f29e2f3966ae615d77c722"
pn.AddPayload(payload)
client := apns.NewClient("gateway.sandbox.push.apple.com:2195", "dev_ck.pem", "dev_pk.pem")
resp := client.Send(pn)
alert, _ := pn.PayloadString()
fmt.Println(" Alert:", alert)
fmt.Println("Success:", resp.Success)
fmt.Println(" Error:", resp.Error)
}
It seems new connection will be created for every payload. I don't know if I am wrong. Is it possible to keep a long live connection?
as described in https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html under Table 3-2 Child properties of the alert property
Digging through the APNS documentation it looks like they intend for the connection to be left open, so I'll split this functionality up. The current approach will be available for one-offs and there will also be a way to keep the connection open.
Omitting the badge count in payload sets the badge count to -1 after adding payload. This is problematic if the notification should be silent, setting 'content-available' to 1 as stated by Apple:
"For a silent notification, take care to ensure there is no alert, sound, or badge payload in the aps dictionary. If you don’t follow this guidance, the incorrectly-configured notification might be throttled and not delivered to the app in the background, and instead of being silent is displayed to the user."
The hack in the following function is introducing the issue:
func (pn *PushNotification) AddPayload(p *Payload) {
...
// Still a hack though :)
if p.Badge == 0 {
p.Badge = -1
}
pn.Set("aps", p)
}
I am getting this error
Error: dial tcp: lookup gateway.sandbox.push.apple.com on 202.131.104.2:53: no such host
Earlier it was working fine can you please let me know what is the issue here.
Hi, your implementation of the APNS is pretty good!. I'm wondering if you plan to create one for Safari Push Notification service:
https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NotificationProgrammingGuideForWebsites/PushNotifications/PushNotifications.html
Thanks in advance.
It seems apns
disconnect from Apple's APNs server and establish a new one from the source code:
conn, err := net.Dial("tcp", client.Gateway)
if err != nil {
return err
}
defer conn.Close()
tlsConn := tls.Client(conn, conf)
err = tlsConn.Handshake()
if err != nil {
return err
}
defer tlsConn.Close()
Keep your connections with APNs open across multiple notifications; don’t repeatedly open and close connections. APNs treats rapid connection and disconnection as a denial-of-service attack. You should leave a connection open unless you know it will be idle for an extended period of time—for example, if you only send notifications to your users once a day it is ok to use a new connection each day.
So is it a problem to disconnect and reconnect each time? Is there an option to keep the connection? Thanks.
Hi! i just made a modification to the library to be able to send notifications through a rest service of app engine, i'd like to share that, so i want to know if you agree.
Regards.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.