0

i have a problem. I have a web view with a page where you receive regular messages... this messages are converted, from the app, to local notification. So no need to use server or services like Parse.. just local notification. The problem is that when I press the home button I receive only 1/2 notification then the app goes "offline" because we are not using it... So the only solution is to keep the app active in background... how I can do that ? Thank you in advance.

MarcoCarnevali
  • 671
  • 8
  • 23
  • This might point you in the right direction. Your options while in the background are pretty slim but perhaps a scheduled timer that performs your logic every X minutes. https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html – anders Nov 03 '15 at 14:45
  • @anders so is no possible to keep it open "forever" i mean every time there is a notification ? – MarcoCarnevali Nov 03 '15 at 14:51
  • I don't believe so no. I'm not 100% clear what you are trying to accomplish but it sounds like you should be using remote notifications though APNS. – anders Nov 03 '15 at 15:14
  • i'm afraid of it... the problem is that this website it's not mine so my only option is to use local notification i think... This app uses javascript to detect a new message and then the app convert it into a local notification. – MarcoCarnevali Nov 03 '15 at 15:18
  • @anders I'm okay using APNs but the problem is... How? because the website to detect the notification need to be open no? – MarcoCarnevali Nov 03 '15 at 15:19
  • check my answer, hopefully thats more clear – anders Nov 03 '15 at 15:30
  • To use APNS you need both server to send notification and client (device) to receive it. So if it's not your website you're out of luck. Because you can't keep your app running in background just to wait for a new message. iOS will terminate the app. – kientux Nov 03 '15 at 15:31
  • Maybe you're not completely out of luck. You can build your own server running javascript to detect new message from the website then send remote notification to device. – kientux Nov 03 '15 at 15:32
  • @kientux good idea, the problem is that is a login website... so it's not the same for all... – MarcoCarnevali Nov 03 '15 at 15:35

1 Answers1

0

Setup an APNS server on your backend. When something important happens send the push notification to the phone(s). You can configure the APNS payload to launch the app in the background and do something more for you such as fetch more content, etc.

Couple things to keep in mind though, users can disable the background launch of your app through APNS AND push notifications are not guarenteed.

Launch app in background automatically?

Community
  • 1
  • 1
anders
  • 4,168
  • 2
  • 23
  • 31
  • i know that... as my last comment the problem is that this is not my website.. so i can't change it what i did is injecting the javascript from my app to convert the message to notification – MarcoCarnevali Nov 03 '15 at 15:32