push notification doubts

Discussion in 'iOS Programming' started by chhoda, Jun 30, 2009.

  1. chhoda macrumors 6502

    Oct 25, 2008
    Hi All,

    I was trying to explore push notification in detail.
    I went through this link


    now it says UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound
    only these 2 types notification are there ?

    can i wake my application up when some notification arrives ? how to do that ?

    what setup do i need to do to set a notification at server end ? I mean assuming I wrote a push application, can i test it on simulator by setting push notification in server side ? If yes how ?

  2. Luke Redpath macrumors 6502a

    Nov 9, 2007
    Colchester, UK
    You can't automatically wake your app from a notification, you can display a badge, a sound or a message (or a combination I think).
  3. jagatnibas macrumors regular

    Jul 28, 2008
    clicking on the message

    can i wake my application if the user clicks on the message ?

    how is the message displayed ? there does not seem a notification constant for it !

    any tutorial / example ?

  4. fishkorp macrumors 68020


    Apr 10, 2006
    Ellicott City, MD
    Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16)

    The answers to all of your questions are in the push notification programming guide linked off your dev portal. In short, yes, the message can open the app, it looks like the SMS and missed call notifications do. You cannot test push on the simulator.
  5. drivefast macrumors regular

    Mar 13, 2008
    the message is displayed on your screen in a similar way that SMSes are displayed (application name and the message itself). sliding the control at the bottom of the screen opens your app, and you can access the last notification from your app. if you distribute your app with sound files, the notification can trigger a sound to be played when the notification is received. also you can have the notification attach a red badge to your application icon (this is the most unintrusive way), like the app store has when one of your downloaded apps has an update.

    you will have to have your own server connected to the apple push service permanently. you decide what combination of message + sound + badge you want to send, but the user can inhibit each one of them from their device settings. one thing to remember is that the notification payload itself is limited to 256 bytes total, including json formatting characters, so dont expect to send long messages in a notification.
  6. chhoda thread starter macrumors 6502

    Oct 25, 2008

    Oh ! that's weird. I dont understand why application starting itself on notification is thought too much by apple. I would always need a voip application wake up when got an incoming call, and that time i will have to have a sdp packet definitely more than 256 bytes ! Hope apple changes that soon !

    I was asked by somebody, like can i implement a push notification so that my webservice sends a notification only when i (my iphone) am at specific location ? Is that possible ? If not thrugh push, through something else ?

  7. drivefast macrumors regular

    Mar 13, 2008
    probably for the same reason why phones are made to ring when a call comes in, and the user is supposed to pick up instead of the handset jumping off the hook?... :)

    the push notification is easy, as it would be sent to a "supervising" app as soon as a condition is fulfilled (like the existing of the tracked device in a certain area). now let's talk about the app that needs to run on the tracked device...
  8. chhoda thread starter macrumors 6502

    Oct 25, 2008
    Thanks drivefast

    Actually for the ringing to happen in an iphone voip [SIP App] there has to be a socket put on notification and it receives a notification and wakes the app up. So, this instruction for incoming call [SDP packet] might be more than 256 bytes !

    Anyway, coming back to my proposed application, I have some devices registered to some push service. I need a message displayed when he reaches LosAngeles and another message when he reaches Seattle. SO how would my server code look like ? How would the server know iphone's location ? i know i can use location manager at iphone's end to determine lat long ... but how would server know it ?

  9. Jeremy1026 macrumors 68020


    Nov 3, 2007
    Also not possible. The phone does not talk to your server while your app is not running. Push notification is essentially made for external information changes. A website updates, the weather changes, the world ends. Not for internal information changes, battery changes, location changes, phone calls.
  10. drivefast macrumors regular

    Mar 13, 2008
    it may be a little complicated, but try thinking differently for a moment. instead of having your phone ringing because it received an INVITE, it will ring because it received a remote notification. on the origination side, i would have an INVITE go two ways, like in a simultaneous call. one goes to the receiving device (iphone / ipotouch), the other one goes to your notification provider server. the notification provider server will match a destination (sip address) with a device token in the database and will send out an apple notification that will... um, make the destination phone play a notification sound. as soon as the user slides the bar showing up together with the notification, the voip app starts, REGISTERs quickly and then receives the INVITE coming on the other path. i'll let you do the rest. :)

    the only way the server would know a device location would be if the device would report its location to that server. as for the rest of the app, i think you should put more effort in defining the actors and the behaviour, because i cant really understand who's "he" who reaches LA and who's "I" that uses the location manager.
  11. chhoda thread starter macrumors 6502

    Oct 25, 2008
    > the other one goes to your notification provider server

    Means I will have to fiddle with my service provider's server ? Some kinda plugin to determine if the incoming call is for iPhone send message to notification server as well ! I cant do that in client's end because a sip client in a pocket pc / palm might call a sip account in iphone.

    Pardon my bad english ! Jeremy and you have answered my question ! If I will have to report my location to server, I will have to run my application, and any application ain't running in background. So it is impossible to notification happen when a iphone user is in particular location ;) Thank you

  12. drivefast macrumors regular

    Mar 13, 2008
    better yet, you will have to be your own service provider, and have your own proxy + registrar + notification server. :) which is not impossible or extremely difficult or hugely expensive. but you have to have your ducks in a row in what concerns the architecture, before you even get started with the iphone app.

Share This Page