I am building a WCF REST web service that is called by the mobile app to insert the Apple device Token into the database. I would like to validate a device token before inserting into the database. Is there anyway to validate a device token to know if it is valid??
I have searched around the forum and could not find any sample code (in .NET) to do this, there were recommendations that I should use the Apple FeedBack service but how do I do that in .NET??
Could anyone please provide me a piece of sample code to validate an Apple Device Token in .NET.
Many thanks,
You can't validate the device token. The only thing you can validate before inserting the token to your DB is that its length is 32 bytes (in binary representation) or 64 Hexadecimal characters (in a String representation).
Beyond that, you should check the responses from Apple to see if you get an InvalidToken error response. If you do, you know the device token sent with the message that causes the error is invalid.
The Feedback Service does not return invalid tokens. It returns valid tokens of devices that uninstalled your app.
I can't give you any C# code, but PushSharp should support calling the Feedback Service and reading error responses from Apple.
This is the little irrelevant answer, but recently i came across this question, as my problem was that i have long list of Notification Token and in that some of them are invalide.
So i need to filter them, but there is not easy way for that but there is 1 app that i use to send/test notification certificate,
Knuff : https://github.com/KnuffApp/Knuff/releases
In that if you give it wrong notification token than it will display error like this,
So that way anyone can validate the push notification token.
Hope it will help user like me.
Related
I'm implementing the Socrata API to be able to parse publicly-available data from the City of Chicago open data set. I am really just concerned about the data itself, so I did not initially think that I would need to implement OAuth2 through an app exposed via ngrok to be able to GET the data.
My initial attempt was to take the GET requests mentioned in their documentation and try to get responses through Postman.
Here's an example of such an attempt:
I also added my Socrata App Token as a param in the querystring, but the same message was shown.
So I tell myself, ok, maybe they deprecated GET requests without making the client go through OAuth2. If they didn't deprecate these GET requests, I would prefer not to have to deal with OAuth2, but I began implementing the authentication process and everything went successfully until I got to the following instructions found here:
I have every single value that needs to be included in that POST request except for 'authorization_type'. Where does this come from? I tried leaving 'authorization_type' in as a string, but received a response similar to the 'Invalid username or password' message in the top image in this question.
Are you only accessing public datasets from Chicago's data portal? From your screenshot it looks like you're trying to access the Building Permits dataset, which is public.
Authentication is only required for modifying datasets or accessing private data, so chances are very good you don't even need to authenticate. Just include an application token with your request for throttling purposes.
Glad to help you figure out your OAuth workflow, but it sounds like it might be unnecessary.
We have implemented a gateway service and push manager services to send push messages to GCM.
Now we want to do some automated testing.
How we can test GCM tokens?
We can get some tokens from real devices and after sometime they might expire and tests will fail. To test positive and negative scenarios we need known valid and invalid GCM tokens.
Any help guys?
Thanks.
Okay, so I may have misunderstood the question, thinking that you were asking how to test registration tokens.
If by test GCM tokens you mean the registration tokens, it is commonly generated upon app installation. With that said, you don't only receive them when using devices, you can also get one when using an emulator (I for one use it all the time for testing).
For valid, this one is pretty simple. First token you het upon installation should be good.
For invalid tokens, I think anything that isn't a token (random string and stuff) will be treated as invalid. One thing though is expired tokens, wherein you have to force call the onTokenRefresh() to generate a new one, making the old one expired.
I am using the Google Cloud Messaging services described at https://developers.google.com/instance-id/reference/server but I am getting a HTTP response status of 400 and this response text:
{"error":"InvalidTokenVersion"}
At the time I write this, that exact error code has zero results on Google! Has anyone else encountered it? I could understand "InvalidToken" but it is the "Version" bit which is confusing me.
I'd like to see a nice list of all the possible error codes for the https://iid.googleapis.com/iid/info/ and https://iid.googleapis.com/iid/v1/*/rel/topics/* services, if you know where that is?!
All the GCM pages say at present is...
HTTP status 400 (Bad request) - request parameters are missing or invalid. Check error messages for detailed information.
Background information:
I am using a registration token from an Android device which still shows a log of successful notifications in the GCM Diagnostics (part of Google Play Developer Console). So surely the token cannot be wrong?
If I try a token value of "bum" I get error "InvalidToken" instead.
However, trying to send a new notification with https://gcm-http.googleapis.com/gcm/send results in the "InvalidRegistration" error, so I guess something has gone screwy.
I'd like to claim that I've changed nothing recently, but something to do with SSL on the server might have expired I suppose.
The token you are providing is regId not instanceId.token. Follow the documentation:
https://developers.google.com/cloud-messaging/android/client.
see examples here.
https://github.com/googlesamples/google-services/tree/master/android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart
Im developing push notification server that works with google's C2DM service.
When I get "Update-Client-Auth" in the response header , I replace the previous token , for use on the next push notification.
When I send notification right after I got new token , it fails -
with the response - "InvalidRegistration"
My questions are ?
How to avoid this ? Should I wait before I use the new token ?
When do I need to start using the new token ? is the expiration date included on header should be used ?
I havent found this phenomenon mentioned anywhere.
thanks for any advice.
I don't think the problem is with your Auth. token.
"InvalidRegistration" means that the Registration token of the device to which you're sending the C2DM Message is invalid. You should make sure that the device sends you an updated Registration Id/token if it changes (apparently it can).
Clear your server cache/DB and start again by getting the device to re-register with Google and then send the registration token to your server and see what happens.
Of course, I'm guessing you don't have lots of registrations in your DB, if you're still in development...
Regards,
Mark
I have to build an App that need authentication over a DB (online).
When application load, at first appear a login screen to insert user credentials.
Thus after a correct login, user can access every areas of this app.
I think to use this steps, what do you think about?
1) Build a PHP (or other lang) Webservice that accept username/password(crypt) and check this data. When user is found, create a token with some strange unique string and adding a expiration time information. Send token back as response with some sort of json structure.
2) The IOS APP call this service passing username/password, if the webservice response is positive, store the received token in NSUserdefault and add time of creation (so i can calculate when it expire.
3) From my APP i can make request toward webservice sending my token. WS checks Token validity and send back a response.
Is this a good practice ???
Yes and no.
I think your approach will work as you wrote it. But keep in mind, that your users needs an internet connection to use your app. So I would design the structure in a way it has also a use for the user, if he has no internet connection.
I also don't know how good your expirience is with Webservices and the communication with them. If you send the data, you should also encrypt the sent data, because they are the credentials of the user. So it's not save to send them as GET Values for examples in a PHP script...
I hope my answer did help a little bit. If you have specific questions on this type of webservice, just ask. I did this a few times before. ;-)
Sandro Meier