Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I store iOS Device Tokens on sql database?

I am making an iOS app which receives push notifications. Everything is set up correctly, and I have made it work already. The way I tested it was to manually enter the device token of my own phone in the .php file which sent the notification. I know I need to set up an SQL-database which stores all the device-tokens. I also know I have to "call" this website in the dedRegisterForRemoteNotificationWithDeviceToken in Xcode. I know how to do all this, but I am not sure how I should create the field for the actual token in the database, and how to parse it correctly.

If I remember right, when I NSLog out my device token, I get something like "< xxxx xxxx xxxx xxxx >". I think I have to parse this to be "xxxxxxxxxxxxxxxx".

I'm sure I'll figure this out.. My main question is, what TYPE should the column for token be? INT? VARCHAR? I can tell that it's a hex of some kind, but I don't know how to go about that in the database..

I'm thinking of setting up the table just with (TokenID int AUTO_INCREMENT, Token (??) UNIQUE);

I do not need users or anything.. Just the token(the TokenID is just my standard procedure..). This is a kind of "news"-notification specified for one field. Anyone knows what type my token-value should be? And maybe also how to parse it from "< x-x-x >" to "xxx"

like image 842
Sti Avatar asked Jul 18 '12 16:07

Sti


1 Answers

I found an example here: http://www.easyapns.com/mysql-tables

 `devicetoken` char(64) NOT NULL,
like image 67
Sti Avatar answered Oct 11 '22 13:10

Sti