I'm trying to test talking to apple's push notification sandbox server.
I made a certificate following this link
(enabled push notification, requested certificate authority, uploaded, generated cert, export p12)
I made a sample C# console application that looks like the following
PushBroker push = new PushBroker();
var appleCert = File.ReadAllBytes(#"devapns.p12");
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;
push.RegisterAppleService(new ApplePushChannelSettings(false,appleCert,"password"));
push.QueueNotification(new AppleNotification()
.ForDeviceToken(token)
.WithPasskitUpdate());
push.StopAllServices(waitForQueuesToFinish: true);
When I run I get
The maximum number of Send attempts was reached
The version of PushSharp I'm currently using is 2.2.1.0
Is there something else I need to do? Do I need to enable SSL somewhere? Is my certificate not properly installed on my local machine. I'm not sure where I am going wrong.
NOTE: the p12 file is about 3KB
I installed the development certificate on my local computer just for testing when running this console application
UPDATE:
I managed to get notifications successfully being sent to apns. However, the only problem is that passes do not update on the user device. According to this link, my webservice is to get a list of valid serial numbers once invoked by the device after receiving a passbook update notification from APNS. However, this never happens.
It seems as if I can successfully send my notification to the Apple Notification Service, but from there the apns cannot send it to the device. Any thoughts?
Right now I am signing the pass and sending a notification to APNS using the same pass type ID certificate.
So I was finally able to update a pass in passbook using APNS. It was an arduous process and there were many different things I didn't take into account. Here are a couple things to keep in mind.
Be sure you use the same .p12 file when signing the pass and using pushsharp. (I had originally used a different .p12 associated with regular push notifications). So the link I originally posted in the question is a tad bit misleading, you would follow those steps for regular push notifications. But for passbook notifications, you need use the .p12 file associated with your Pass Type ID
In PushSharp, be sure to disable the production/sandbox certificate check. There is no sandbox environment for passbook, so everything should point to production. In this line, add an extra true parameter to disable the check
push.RegisterAppleService(new ApplePushChannelSettings(false,appleCert,"password", true));
Be sure you aren't using a test device when testing. Also you cannot use the simulator
The push token you receive is different than the DeviceIDToken you would receive when registering for regular push notifications. The push token is passbook exclusive
Ensure the proper certificates are installed on your server. For example I had to install the pass type ID certificate
Do a telnet feedback.push.apple.com 2196 to ensure you can hit the apns server
Related
i'm new to ZKteco devices! I am using a Zkteco device. I have a Zkteco Device and I have downloaded a standalone SDK, but this SDK doesn't trigger the events, (for example OnVerify, or OnAttTransaction).
So, I read in some articles, that I need to use Push SDk, but I can't find it.
I took one month to find that for that PUSH SDK and ADMS, clearly ZKTeco is not open to share that. so I had try to proceed otherwise. Here is the solution I had implement and it work properly.
The push SDK is just HTTP request made by ZKTeco device to the Bioserver.
You can use a tool like Wireshark to scan HTTP requests made by your device and implement same request/response on your own server.
For exemple, the ZKTeco device model MB560-VL send requests like this one
GET http://[SERVER-IP:PORT]/iclock/getrequest?SN=XXXXXXXXXX
and if like the BioTime software, your server just send
OK
as response in text/plain, your device will view your server as a "BioTime"
Note that your ZkTeco Device should have ADMS support, so that you will first configure SERVER-IP and PORT on the device (see your official device documentation on ZKTeco website)
User registration
When a user is registered on the device, the device send this request
POST /iclock/cdata?SN=XXXXXXXXXX&table=OPERLOG&Stamp=9999
with user information on the HTTP buffer. something like this one
PIN=2\tName=Johny Deep\tPri=0\tPasswd=\tCard=\tGrp=1\tTZ=0000000100000000\tVerify=0\tViceCard=\tStartDatetime=0\tEndDatetime=0\n
your server should just parse this data and respond OK to this request
User logs (clock_in / clock_out) Device request
POST /iclock/cdata?SN=XXXXXXXXXX&table=ATTLOG&Stamp=9999
the data sent by device on HTTP data buffer looks like
2\t2022-07-12 16:00:20\t1\t15\t\t0\t0\t\t\t43\n
As you can see you parse this string with '\t' as the separator of informations
the first integer is the User-PIN,
the second part is the date and time,
the third part is clock-in if value==0 and clock-out if value==1
Here is an exemple of implementation with Python
#http.route('/iclock/getrequest', type='http', auth="public", csrf=False)
def zk_bio_device_ping(request):
print("----------DEVICE PING-----------")
print(request.GET)
return HttpResponse("OK", content_type='text/plain')
#http.route('/iclock/getrequest', type='http', auth="public", csrf=False)
def zk_bio_device_push(request):
print("----------DEVICE SEND DATA----------")
print(request.GET)
print(request.body.decode('utf-8'))
return HttpResponse("OK", content_type='text/plain')
Device do not use any authentification to communicate with server ! I'm pretty sure that's a big security issue.
I'm grabbing a self-signed piv auth X509certificate from a smart card inserted in a USB reader and am attaching it to the HttpWebRequest via the code below:
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(uriInfo);
Request.ClientCertificates.Add(theCert);
Request.Method = "POST";
//get the response back (the mini driver will prompt for a PIN at this point)
HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();
Here is the thing that is confusing me, this code works on some machines but not on others. It's worked on Win7 on one machine and not on Win7 on another, it works in Win8. I've even tried running it in a Virtual Machine of Win8 which works, which is a guest of a Win7 host machine that doesn't work.
I've read a lot of articles on stack overflow, and tried many different things to get this to work, but nothing seems to. Since my certificate doesn't contain the private key info, that seems to be why it is not included in the request? Which is similar to this question: HttpWebRequest doesn't seem to be sending a client SSL certificate
Since it works on some machines and not others is this something I need to configure differently on the machines where it is not working?
I know the cert is not being attached because of some wireshark investigating. The certificate I'm using has been set up on the server, so it should trust it (and does in some cases).
Some things I'm doing different than other posts is I'm getting the cert from a piv smart card and simply attaching it to the request. When I call GetResponse, the microsoft minidriver steps in a prompts for a PIN to be entered. But since the certificate is not being attached to the request, I never get the prompt for the PIN and the server returns a 403 Forbidden error.
Any ideas?
(This is my first post here, so please forgive any sins which I've committed)
Ok, I finally found out what the problem was. I noticed that the when the smart card was inserted into the reader, the certificate was not propagated to the personal store. Then I found that the thing responsible for doing this was the a service called "Certificate Propagation".
I noticed that service was not running and when I tried starting it, it would stop right away giving the message,
"The Certificate Propagation service on Local Computer has started
then stopped. Some services stop automatically if they are not in use
by other services or programs."
After some digging on why this service would start but not stay running I found it was due to a Group Policy setting stashed in the registry. Changing the following registry setting from 0 to 1 fixed the issue for me:
HKLM\Software\Policies\Microsoft\Windows\Certprop\CertPropEnabled = 1
We are trying to use the NotificationHubClient in Microsoft.ServiceBus.Notifications. We are having a strange problem which the code below shows where we register the Device like so:
NotificationHubClient client = GetHubclient();
var task = client.CreateMpnsNativeRegistrationAsync(deviceToken, tags);
Task.WaitAll(task);
This registers the device fine and if we send a test toast message from the azure portal debug page it comes through to the windows phone without issue. However if we call the following:
var sentTask = client.SendMpnsNativeNotificationAsync(GetPayload());
Task.WaitAll(sentTask);
private static string GetPayload()
{
return "<wp:Notification xmlns:wp=\"WPNotification\"><wp:Toast><wp:Text1>Great News</wp:Text1><wp:Text2>Great News</wp:Text2></wp:Toast></wp:Notification>";
}
No toast notification arrives on the phone and if we then go and try to send a test toast notification again from the debug page of the azure portal it no longer works and the following error is displayed:
The Push Notification System handle for the registration is invalid
None of this is making sense, we have enabled testSend and there are no errors coming back from the client in the code, in fact it says everything was successful the first time even though this appears to break the PNS handle.
Has anyone come across this before?
It turns out that if the Xml declarations are missing:
<?xml version="1.0" encoding="utf-8"?>
Then you can no longer send push notifications to any phones you tried to send a push notification to as it is invalidated. This seems pretty awful, sure don't send the notification if the payload is invalid but why invalidate the PNS.
I'm working on a project which receive notification from GCM server.
I've got the registration ID from GCM server and i send it to my server application which save it in the database.
My device receive the message but when I try to send another one, the precedent is replaced.
I know that we've 2 types of message:
Collapsible "send to sync"
Non-Collapsible
So without changing the name of the message, how can I get two message send at different time?
UPDATE 1:
When my device is offline (for example airport mode activated), I try
to send for example 2 messages from my application server to Google
server (I read that Google stores all the messages). But when I
desactivate this mode, I receive only the last message sent.
I use different collapse_key for different message and I receive all
of them (of course when the device online).
Is anybody knows how can I fix this?
The collapse key is relevant only to messages that were sent to the GCM server but haven't reached the destination device yet (if more than one such message has the same collapse key, only one of them will be sent to the device when it becomes online).
In your question you describe a different situation - the first message is received by the device and then the second message is received by the device and replaces the original message. That has nothing to do with GCM. It has to do with the way your application handles the received messages. For example, if your application code that receives the message displays is as a notification, it's up to you to decide whether a new message will override the existing notification or create a new notification.
You need to make sure that the value of the 'collapse_key' field in each message is different
I'm trying to send a push notification using https://github.com/Redth/PushSharp
I'm using the sample project as is (having commented out the non ios stuff from program.cs), I confirmed that the app i'm using is the correct app, I've regenerated the developer push cert.
I'm running the app from xcode, so that it is devlopment providsioned..
The message seems to go fine, but then comes back
Waiting for Queue to Finish...
Sent: Apple -> {"aps":{"alert":"1 Alert Text!","badge":7,"sound":"default"}}
Queue Finished, press return to exit...
Device Subscription Expired: Apple -> [Device Id Removed]
I'm getting the device id from my app, to confirm it coumes out broken into Hex Octets, and i simply remove the spaces
So... not sure where to go from here, seems that apns is saying the app doesn't exist on my device, but it certainly does..
This is almost always due to a mismatch between the development and production provisioning profile certificates.
Check you're using the correct one... if this is still a problem!