Coder Social home page Coder Social logo

apns's People

Contributors

anachronistic avatar benkraus avatar coccodrillo avatar draaglom avatar garethstokes avatar mrtravisb avatar ykxpb avatar yujisuzuki 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apns's Issues

badge string?

Hi,
i can't set badge '+1' on payload. My app can't increase counter.
Can you change type of badge payload like string?

Error: EOF

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 return value from apns is different from the apple document

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.

Error: encoding/hex: odd length hex string

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

can you help me please

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)

}


Clarify license

Can you please clarify what license this project is released under?

Don't send badge value

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?

Error: crypto/tls: failed to parse private key

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

Max payload size increased to 2kb

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.

iOS 8 Interactive Notification Support

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.

x509: cannot validate certificate for 17.110.227.92 because it doesn't contain any IP SANs

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

resp.Success = false and resp.Error = NO_ERRORS

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.

Looking for a maintainer

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.

Send many many push notifications

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?

Help, I happen an "EOF" error

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)
}

New connection for every payload?

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?

Separate ConnectAndWrite to support persistent connections

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 Badge count in payload results in Badge set to -1

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)
}

Does it keep the connection?

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()

While Apple says: (https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW1)

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.

Apns on Google App Engine with go

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.

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.