I'm trying to send an Apple push notification from a Go appengine site. I'm using the apns2 library as follows:
cert, err := certificate.FromPemFile(pemFile, "")
if err != nil {
log.Fatalf("cert error: %v", err)
}
client := apns2.NewClient(cert).Development()
n := &apns2.Notification{...}
if res, err := client.Push(n); err != nil { ... }
On a local development server, it works fine; but in production I'm seeing:
Post https://api.development.push.apple.com/3/device/995aa87050518ca346f7254f3484d7d5c731ee93c35e3c359db9ddf95d035003:
dial tcp: lookup api.development.push.apple.com on [::1]:53: dial udp [::1]:53: socket: operation not permitted
It looks like appengine expects you to use its own urlfetch library when sending outbound requests, so I tried setting the underlying HTTPClient to use that:
client.HTTPClient = urlfetch.Client(ctx)
However, the response from the Apple server is now
##?HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 504f5354202f332f6465766963652f393935616138373035
I believe the problem is that Apple push notifications require HTTP/2, but urlfetch only implements HTTP/1.1.
How do I solve this problem? Is there a way for an appengine app to send an HTTP/2 request?
This would require going through the App Engine Sockets API. The documentation states:
Libraries that can accept a net.Conn should work without modification.
You can get a net.Conn from the appengine/socket package and pass it to a lib that will accept one, but in the case of apns2 it doesn't allow you to do this. However another user has submitted a pull request to the apns2 project that adds a distinct GAEClient which can use App Engine sockets.
As of right now it looks like the commits still have not been pulled into the master branch, however you could still merge these updates manually into your own source tree as a workaround for now.
I dont know much about go appengine, but whatever it looks from the code, your client := apns2.NewClient(cert).Development() line seems to be defective, i think for production, you dont need development cert, you need to have distribution cert. So check that is there any option available for it. Also, is certificates from apple's dev site are generated by you or by go appengine. If you have manually created that, then you have to create 2 types of certificates, one for developement and one for distribution/production, and when app is running in production mode, you need to use that certificates.
Related
same issue, other person: https://github.com/signalapp/Signal-iOS/issues/2282
We've checked out the Signal-iOS repository and we're trying to make it connect to another server. We're running an instance of the server at signal.appcraft.nl. We've modified the defines in SignalServiceKit/src/TSConstants.h to match our server and we've changed the domains in App Transport Security Settings in /Signal/Signal-Info.plist
We also cloned the Android app and that one we managed to got working just fine. The iOS app seems not to be able to connect to the internet at all without a clear error. The first HTTP call that is done is GET https://signal.appcraft.nl/v1/accounts/sms/code/<MYNUMBER>?client=ios. When we invoke that URL using curl, we get a response (and SMS) just fine. From the app, we receive a Signal was unable to connect to the internet. Please try from another WiFi network or use mobile data. error. We also changed NSAllowsArbitraryLoads to Yes.
We've added a breakpoint in /Signal-iOS/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m:292
# /Signal-iOS/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m:292
(lldb) expr error
(NSURLError *) $3 = 0x00000001c0244800 domain: #"NSURLErrorDomain" - code: 18446744073709550617
Please advise
I am trying to do a push notification from the browser console using raix (version 2.6.1).
I have tried pushing using the php script from this tutorial and it works with the certificate and key I have, but when I tried it with raix, nothing happen on the phone. I tried doing:
Push.send({from: "pushfrom", title:"hello", text:"world", token:{apn: "my_ios_device_token"}});
This is my config.push.json
{
"apn": {
"passphrase": "xxxxxxx",
"key": "aps_key.pem",
"cert": "aps_cer.pem"
},
"badge": true,
"sound": true,
"alert": true,
"vibrate": true
}
I have insecure package, but still, I tried adding the Push.allow and it didn't help.
How do I know whether the notification is actually being pushed to APNS or nothing is happening at all?
I'll try giving as close to an answer as possible:
Try using the $ meteor shell server console to send messages, server doesn't require allow/deny rules for sending (it's a client-side security)
Behind the scenes theres actually two collections:
Push.notifications - containing the pending notifications to send (these are queued)
Push.appCollection - This one keeps and maintain the tokens (eg. removes tokens if revoked by gcm/apn services)
So you can use the meteor shell to check if the client app registres a push token - if it does then you should be ready to send a message to it eg. directly via the meteor shell.
If you don't get tokens from the client in the Push.appCollection - then you have a config or certificate issue - that's the hard part of push notifications.
If you get tokens into the Push.appCollection then it's prop. something with the server setup. This could be certificates, I've added a guide on the raix:push repo for testing server certs. Also think in ports, you need to have some ports open for your server to communicate with the gcm/apn service. Also think in firewalls etc. depending on your/client setup and security level on the wifi etc.
Please help out improving documentation on the project - I built the thing and take alot for granted, so there might be a missing clue etc. the documentation.
You can also use the query: {} instead of sending to one specific token (while testing)
Latest version is at 2.6.6,
Push notifications is besides scrolling the smallest hardest feature to work with.
Kind regards Morten
I am using PushSharp for Apple Push Notifications and it is working from console app and windows service on Windows 8 and Windows Server 2008R2, but the same code transferred to WebApi app on the same computers does not work. I've installed certificate and private key via mmc in Personal (the private key is available, granted permission for IIS_USRS) and Trusted Root Certificate Authorities.
Code is kind of obvious, but just in case:
var push = PushBroker();
var appleCert = File.ReadAllBytes("C:\Users\Documents\Certificates\Push.p12");
push.RegisterAppleService(new PushSharp.Apple.ApplePushChannelSettings(false, appleCert, "pwd"));
PushSharp.Apple.AppleNotification notif = new PushSharp.Apple.AppleNotification()
.ForDeviceToken("xxx")
.WithAlert("Updated...")
.WithBadge(1)
.WithSound("default");
push.QueueNotification(notif);
//Wait for queue to finish
push.StopAllServices(true);
No errors/exceptions etc., its just the iPhone device does not get notifications when initiated in WebApi app.
Have you checked all the event handles for errors? There's alot of them on the PushBroker instance where you can subscribe to intercept the error (if there is any).
Subscribe for: OnServiceException and OnNotificationFailed.
Check if the IIS|app|users|roles has all the privileges to access the web.
When I had this error it was a certificate issue. Make sure you are using the correct certificate for production, since the first parameter is false in ApplePushChannelSettings, otherwise the message will not get delivered. Also step through the code and see if any errors are being generated but not logged.
I am Java Developer but recently I got some project related to BlackBerry Push Service implementation. My objective is to write the server side implementation for the Push Initiator i.e. the content provider. but to test this I need to use some sample push enabled app also.
I have gone through the BB Developers guide and have done below steps:
Registered for BB Push service evaluation API and received the confirmation mail with all the required details like: appId, pwd, PPG Url for BIS, port number etc.
installed the BB Push installer for low-level-Push-Imitator(i.e. the web app content provider) and the sample push enabled app(PushDemo_sample available on BB Push service Developers guide).
Now I am testing this push-enabled app on simulator and trying to register. But as the sample app tries to first subscribe with the Push-Initiator(CP) before registering with BB Push server. I have commented the below code as I don't want the subscription part.
The RegisterCommand class handles the subscription and registration.
protected void execute() throws Exception {
// first we register with Content Provider
Logger.log("Reached RegidterCommand execute() method .. but eacapingCMD_SUBSCRIBE");
//ContentProviderProtocol.performCommand( ContentProviderProtocol.CMD_SUBSCRIBE, username, password, isEnterprise, tx ); // commented
// if the registration is successful we register with BPS
Logger.log("Now Going to register with PPG");
BpasProtocol bpasProtocol = PushLibFactory.getBpasProtocol();
bpasProtocol.register( tx, isEnterprise );
// update the registered state
PersistentStorage.setRegistered( true );
}
But after configuring the app with the proper appId, PortNumber and BPS server URL, dummy push initiator application url, When I clicked on register, It is showing some IOException:
Command 'register' failed with error: java.io.IOException: could not find a service book entry for IPPP.
In the app logs on simulator I can see that it is trying to open the BB Push eval url with some parameters appended after the url like below:
Opening URL: http://cpXXXX.pushapi.eval.blackberry.com/mss/PD_subReg?serviceid=XXXX-sxxxxxxxxxxxxxxxxxxxxxxxxxxxx&osversion=7.1.0.318&model=9900&deviceside=false&ConectionType=mds-public
Here I am just trying to register my simulator with the BB Push server. Is it not possible to test the Push service on simulator? or I am doing anything wrong?
and one more doubt how the register() method of PushLib50 class of the sample push app is appending the extra parameters after the eval URL?
Please help. Point out if I am doing anything wrong to implement the push service.
You cant test push notification in simulator. you need real device for that.
Refer this site
The BlackBerry Push Service is an essential component of the real-time, always-on experience of BlackBerry smartphones. It offers an efficient and reliable way of sending information to your users. It also lets your application process information in the background and notify users when their attention is required.
I install the blackberry sdk push server and i get app id and the port and i used the tutorial SamplePushEnabledApp i registred it with those data
Application ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PPG Base URL** http://pushapi.eval.blackberry.com
Push Port: xxxxxxxx
For push initiator application i use the url https://XX.XX.XX.XX:8443/sample-push-initiator/ successfully create application using this, provide APPID, name and service level = Push-Essential. appID is same as provide by RIM.
I am trying to push msg from push menu item but it's give me error INVALID subscribers.
I had add subscribers name as APP_ID given by RIM, I had also tried device PIN No. as subscriber name but same error occurs.
plz help me to solve this issue.
Is there any solution for that?
There are three things required to sent a request from client side: APP id, push port and PPG base url
and three things required to send a response from server side :PPG base url, push username and push password
check whether you are using the exact credentials that are provided by Blackberry. If these dont match, it gives the above error
Though this may be very late to answer your problem/issue faced while implementing push service in BB device, But as, very recently I successfully able to implement this and I know how difficult to do this if you are not a BB app developer.
Hope you have gone through the below url for installing BB push service sdk on your PC.
http://developer.blackberry.com/bbos/java/documentation/push_service_sdk.html
http://developer.blackberry.com/bbos/java/documentation/developing_push_enabled_app.html
So for this if you are able to install the push service sdk(bpss-1.2.0.29.exe) you will be having one BPSS directory and under this the below thing will get created.
apache-tomcat-7.0.26
logs
pushsdk-high-level
pushsdk-low-level
Uninstall_BPSS
Push_Service_SDK_for_Java_InstallLog.log
Now I have used the pushsdk-low-level to push.
you can access this web app(push initiator cum content provider) by
https://localhost:8443/pushsdk-low-level
But before start pushing from this low-level push initiator you need to properly install the sample pushDemo app on your device.
NOTE: You can't test push service using the simulator.
Then you need to register with the Port(XXXXX), AppId(XXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXX) and BPS server URL: http://cpXXXX.pushapi.eval.blackberry.com, Push Initiator Application URL: http://XX.XXXX.XXX.XX:8443/pushsdk-low-level, and use pubic(BIS) network selected.
Now let me tell you what this sample pushDemo does.
first it will try to use the Push initiator application URL to subcribe/store the BB device PIN to have the information about all PINs that have been register with your Push initiator(here our push-low-level app). But for testing this you can ignore by commenting the below code line in RegisterCommand.java class of the sample PushDemo app
ContentProviderProtocol.performCommand( ContentProviderProtocol.CMD_SUBSCRIBE, username, password, isEnterprise, tx );
Now run this modified app on you device and insert all data required for registration, you will be asked to input username/password, give anything. and register it should register successfully.
Once you have successfully registered your app on your BB device.
Now you should be able to push from your push-low-level web app to your pushDemo client app on your device. NOTE: the address that is been asked on push-low-level push page is nothing but the PIN of your device.
Ping me if you any other help on implementing this.