ios - XCode iDevice app - How to listen for message/request from server? -
i have project need able send messages server running web service specific idevice. have no idea how this, appreciated.
the scenario: have web service receives message idevice (could mac or pc, android device). depending on content of message need able send message web service idevice (i know ip-address of specific idevice). know how use urlrequests send message idevice server , collect response server. in principle every 10 seconds send request server asking if server has new messages sender (the idevice sending request), pretty sure not correct way it. there way have idevice listen server communication on specific port, idevice active when receives message server something, e.g. display message in app listening server communication?
i guess need use similar technology used imessage, how done?
i using xcode 4.6.2, ios 6.1.
edit: clarify needs bit more: apns seems unreliable (at least have read in other threads regarding apn) web service in cases can have need sending 2 distinct message idevice within 1 minute (in cases seconds), , far have read in other threads not possible because of how apple's server handles aspns.
the app developing needs receive messages server when app active - there way, not using apns, this, e.g. making app listen communication on specific port?
your scenario seems pretty similar apple push notifications (apns).
ideally server side should write code in such way if there change on server side & need informed associated devices.
then server should post notification apple server send notification associated devices.
you have can use code identify ios/mac deivce
nsstring *identifierstring = [[nsuserdefaults standarduserdefaults] objectforkey:@"myid"]; if (!identifierstring) { cfuuidref identifier = cfuuidcreate(null); identifierstring = (nsstring*)cfuuidcreatestring(null, identifier); [[nsuserdefaults standarduserdefaults] setobject:identifierstring forkey:@"myid"]; } nslog(@"%@",identifierstring);
this code works till lifetime of app only.
Comments
Post a Comment