-1

Push notifications are not reliable. Apple Push Notification Server does not guarantee the delivery of the notification.

We have an application, in which we present a web view, in which there is a button, that should trigger a request from the client to the server. But as the button is in the web page (presented in the webview), the server sends us a push notification asking us to start sending the request. This is difficult in iOS, because, any notification should be accepted by the user to be called upon, and anyway, push notification can not be always relied upon.

One Alternative to this is to keep polling the server asking if i should trigger the request. But this will work only when app is running, and will drain a lot of battery.

Another alternative is creating a custom URL scheme. But I am not sure how to use that, and if that will work for android as well. Can any one explain on how we can use URL scheme to achieve our goal?

Nikita P
  • 4,226
  • 5
  • 31
  • 55

1 Answers1

1

If you're looking to interact with an app that is not in the foreground push notifications are your best bet. No app is guaranteed to continue running once it's in the background, push notifications give you a way of launching the app and passing it data. Note also that push notifications require the user allow accepting them and can be ignored at will.

URL schemes can be used to launch the app when called from another application, or can be embedded in web pages as a link.

I'd recommend having the button click trigger doing whatever you need to do on the server and using email as a callback with a link to run the app (using a url scheme) or visit a web page with the result.

Richard Brown
  • 11,346
  • 4
  • 32
  • 43
  • can you elaborate a little on "using email as a callback". What if the button click redirects the webpage to a custom url scheme of the app? I can get some information through that, can't I? – Nikita P Feb 19 '13 at 07:30
  • Sorry, maybe I misunderstood your intention. I got from your question that someone would press the button and an action would happen asynchronously on the server. You needed a way to alert the client when the action was complete. Rather than use a push notification I meant that the server could send an email that included a URL scheme to launch the app with an id that it could check back to the server to find the status... myapp://process_id_goes_here – Richard Brown Feb 19 '13 at 07:36
  • I think, I am still not clear. I have a webview inside the app, which opens a webpage (containing a button). On click of this button, the server should send some command to the client to start a connection/request. I do not want any other app to open my app. – Nikita P Feb 19 '13 at 07:47