sync Contacts between iPhone(also Android) and server - contacts

I am in trouble and Need your help.
1st Question:
My IOS app has to send/receive datas to/from a Web Server.
The server defined using the TCP and the data format is TLV; I have never used TLV before, and have no idea how to solve this problem.
As for TCP, I decide to use cocoaAsyncSocket, it's simple to deal with TCP transports;
But I send/receive datas all in the (NSData*) format, I don't know if the server can decode
it correctly.
2nd Question:
I am also trying to sync Contacts between local client and the server; the local client will be IOS app and Android app. Through I decide using vCard as the contacts' data format, but the vCard from iPhone contains some items(such as RelatedName) that not contained in Android; When I using vCard, there are some data lose, I can't solve this problem. Is there any good suggestion?
Somebody help me. Best regards.
=========================
Finally, I decided to use cocoaAsyncScoket for transporting data and use SQLite for storing contacts's all data; And it seems avoiding data lose is not possible.

I completed it.
I used the GCDAsyncSocket lib to send & receive datas;
As for TLV, just send the raw bytes in order under the custom defined rules will be fine.
The lib in github

Related

How to get data from MySQL generated XML?

I have an app to send data from iPhone to MySQL server and I got it with request from objective-c and php on server.
Now, I want to receive data from server by XML. I have created a php code to generate data from MySQL to XML. How can I code in objective-c to call this php code? The goal is using this XML to parse and display on iPhone (I have objective-c code to parse xml file from link on server).
Please help me if you know and used to work on that.
Use Web-servces Like XML- RPC, SOAP ,REST
To connect to a mysql database, your best bet is to use JSON/SOAP/XML/PHP or some combo of the mentioned, to talk between your database and your app..
The reason database connection directly from the device is a bad idea, is that you have to enable global external access to it for it to work. You can keep your data safer by having scripts on your server do the communication to the database.
Your server needs to expose a service of some kind (a URL the iPhone app can call).
Your app can call this URL with NSURLConnection (or lots of others).
This will return you an NSData * object.
Your app will then need to parse this raw data into XML (or JSON or a few others). You can use NSXMLParser (and lots of others) to do the parsing.
Then, you need to translate the XML into useful business objects.

Send link to update DB with Data

In our iPhone app , we offer email templates populated with DB. also user can create their own templates.
Say for example , i have my own templates created over 500 entries to use
here i need to know the possibility on the below things since my client asks me.
If i want to to send my templates stored into my DB to myfriend who uses the same application.( So my friend does not have to create the templets on his own , he can use mine)
Can that user be able to load those template details ( DB information ) into his app? (like posting the db contents to server and the same content can be loaded into his app using link)
I think it cant be done but i would like to know opinions and views to convey this to my superior.
Thanks a lot
This could help: How do I associate file types with an iPhone application?
Okay, well.. It's possible to do what you are trying to do.
You would need to
Serialize the data that's stored in the DB
Figure out a way to send this data to the server/as an attachment in an email over to your friend.
So from that point of view,
Doing the first is pretty simple. If its all just string content, you can serialize it into an XML/JSON. There are a lot of ways out there that converts objects into strings or bytes to send them over the network anywhere you please.
The second needs support from the server. You would need a server that can identify the applications from one another. ie. yours from that of your friend's. It should then be made to handle the serialized content you are planning to send over and then figure out a way to send it to the friend. maybe a push notification? You could possibly look at Urban Airship or some such offering for doing this incase you dont have an existing server.
Or, you can cut yourself all the work and see if your workflow can fit into this
http://www.raywenderlich.com/1980/how-to-import-and-export-app-data-via-email-in-your-ios-app

How can I transfer data from core data via mail in iOS 5?

I am recently making an app which needs to exchange messages between different iOS devices.I decide to use mail to do with the data transfer.And I read a tutorial by Ray( http://www.raywenderlich.com/1948/how-integrate-itunes-file-sharing-with-your-ios-app )
.It tells a way to handle this thing.But my situation is that the data I want to transfer are all stored in the sqlite.I think it's better to convert these data into NSString and than send them.But I have no idea of how to define custom UTI which will specify the specific type,like .myapp which will be sent to the receiver,and how to user can open it and import data in the app.Because I use iOS5,so I can't even follow the steps in the tutorial.By now,i can send email to users with the data,but not with the .myapp attachment.So , can anyone give any advice on how to get the data into .myapp file and how the receiver will get data and import it in the app,specially for iOS5?Great thanks.
I successfully made this work via Email by simply constructing a text file in CSV format (comma separated values) to be attached to the email message. I registered the .csv with my app, added an import handler, and now one can then open the file on the other iOS device running the same app.
However, I found this approach rather clumsy and not very user friendly. Have you considered using the Dropbox API instead? Even better, use the new iCloud interface right built right into the SDK. That seems so much more convenient from the user's perspective.
Another approach could be to send the data to a webservice which informs the receiver by notification (Apple Push Service Notification). Your data is then stored on a central system and can be loaded by the app as soon as the receiver gets the notification and opens the app.

How to send data to webserver and know it comes from a certain application?

I'm trying to send data from my application to a webserver.
The catch is that I want to encrypt the sent data and also make sure it comes from my application. (From what I've read so far it's easy to decrypt the data if it's not sent via HTTPS. On the unique application I didn't find anything except the Application ID Apple provides for each application but I don't know how that works).
The data sent are various highscores and achievements that the user can enable. The thing is that the user doesn't have to type in anything but his username and having that associated with the UDID it should be enough.
But how to make sure it's from my application?
Edit:After reading some responses around here I still didn't understand something:
If someone extracts the IPA and reverse engineers it wouldn't he have access to all my .h and .m so he can look up anything in there?
You could generate a client certificate for the iPhone app, and use mutual authentication for your SSL handshake. Then you know that data submitted to the server come from a particular user of the app, and that your app is communicating with the correct server.
Regarding your edited update, yes if someone reverse-engineeres your app they can probably work out how the high-scores are protected. But seriously, how much trouble do you expect most people to go to in order to fake a high score in a game? Are you offering a cash prize or something?
If you are using HTTPS then you can just put an identifier key in your POST to the web server, either as a field or perhaps an HTTP header that identifies your app. The entire connection is encrypted so it will be protected. If you do this you will want to encrypt the key even in your binary and decrypt it as you send it over the connection, that way no one will be able to pull it out with a hex editor.
Another approach if all you want is to know that the data comes from an authentic instance of your application is to use message authentication codes (MAC). I leave deciding how strongly the key needs protecting as an exercise to the reader - you know your security requirements better than I do.
You can use CommonCrypto - part of the iOS SDK since forever - to actually generate the MAC.

Share Core Data Between Apps

I have a Core Data-based app that keeps records of purchase receipts, and I'd like to know if I can send one specific record (i.e., one row from the SQLite table) from one phone to another via email or whatever. I'd like to have a button that says "send a copy of this receipt to so-and-so" that would email the record that could then be imported. These are very small records that have less than 20 rows.
I know that this has been asked before (Core Data Store Sharing between iPhone Apps), but I'm wondering if anyone who has actually implemented this could share an approach.
Thanks!
If the length of the record you wish to send is no more than 95 Kb, then you may take advantage of GameKit and export/import it using a P2P connection. I do this in one of my apps using Bluetooth as the underlying connection. Otherwise, large records may be handled by a bonjour client/server implementation. Again, this is commonly done when synchronizing data with a desktop application.
In this case, by far the easiest approach is to write a serialization/deserialization method for your entity. I would suggest using a plist with an application-specific extension. You can then load the plist in your recipient and deserialize into the client's managed object context.