I would like to send data to my app, when it is runs in the background. I know its possible to let the iphone do some background tasks, but is it also possible receive data from a server when the iPhone is in the background. So that when the iPhone receives this data, i can change the behaviour of the 'background' app.
I am also aware of push notification, but what i mean is that the user wont be notified.
No this is not possible, there are 3 background apps allowed by apple. Those are VOIP, audio and location based apps.
There is no other way to push data to an app other then push notifitcaions. but your app only receive the notification when the opens the notification.
The only other thing you can do is poll if the server has any new data for your app, but you can't really do this while in the background.
Related
I want an app that can be opened automatically or by itself when app notification appears. I've been looking for this case but I don't find any solution.
This is not possible on iOS. You can not programmatically open an app based on a notification.
What you can do is to use silent pushes (those are push notifications that are invisible to the user) to wake up your application in the background. Using this mechanism, you can do some work in your app in the background (like fetching some data so it is instantly available later on).
Depending on your use case, this might be of use to you.
I'm making an iphone app that uses NSURLConnection to download some data from the web. I need to store this data somewhere, so my app can send out push notifications when the data changes in a particular way. For example, the data being stored is a number and a push notification will be sent out when that number changes by +-10.
I'm new to this, so I'm probably overcomplicating how I think this can be accomplished. I'm thinking I need to create a database and some server-side code that continuously pulls the data. When the data changes to my specifications (ex. +-10), it somehow pushes the data to the app which then sends out a push notification.
Is there an easier way to accomplish staying within xcode dev?
The app doesn't send the push notification. The point of push notifications is your app can be in the background so it can't poll/check for a given condition (like your +-10).
When that interesting even happens server side, it can push a notification to the device. The device can handle that notification by (1) showing text (2) playing a sound or (3) updating a badge on an icon.
So, it's not about your device downloading the data into database (although that has value for offline and occasionally connected scenarios).
So, you'll need a server side component that detects that +-10 change (on data change or polling) and then sends the push to the device. Now, it's possible that devices are sending data to your service (uploading) and when and interesting event happens it could notify other instances of the app.
This link may help clarify push notifications: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
I have requirement for an application which work in background only.
When first time application install on device then after installation that will be go to background. And after two minutes a view will popup on screen.
Now problem is that after installation how to redirect application into background?
i get answer for this that if we want to send our app into background then we have to open another app like as safari. so i get this solution.
Now problem is that how show a view after two minutes from background. I have to create as a demo not for app store. So if anyone have any solution then suggest me.
Thanks
It is not possible to do so in iOS. You can't send an app into the background
If you want your app to get displayed, the only way to do so is through push (from server) or local (from phone) notifications, and the user has to explicitly accept it.
Unfortunately, you can't make it open automatically.
iOS is not designed to run code in the background. There are a few exceptions, for example a music streaming app, or a GPS navigation app, but in general it cannot be done.
Instead, you should run your app on a server in the cloud, and send a push notification to the phone when you want something to happen on the phone. You may also be able to achieve this with "local notifications", depending on what you're trying to do.
Can you have a program running in background respond to SMS? I basically want my program to sit in the background so the will be iOS4+ and when someone text messages you, the app can then do something with that text.
Can this be done?
I have seen that the question has been asked before, but it was before the iphone could have background apps.
No backgrounding is very limited on IOS. There is only a handful of stuff you can do. You can always send push notifications to get an alert while the app is not running in the foreground.
From Apple:
OS 4 delivers seven new multitasking services that allow your apps to
perform tasks in the background while
preserving battery life and
performance. These multitasking
services include:
Background audio - Allows your app to
play audio continuously. So customers
can listen to your app while they surf
the web, play games, and more. Voice
over IP - Your VoIP apps can now be
even better. Users can now receive
VoIP calls and have conversations
while using another app. Your users
can even receive calls when their
phones are locked in their pocket.
Background location - Navigation apps
can now continue to guide users who
are listening to their iPods, or using
other apps. iOS 4 also provides a new
and battery-efficient way to monitor
location when users move between cell
towers. This is a great way for your
social networking apps to keep track
of users and their friends' locations.
Push notifications - Receive alerts
from your remote servers even when
your app isn't running.
Local notifications - Your app can now
alert users of scheduled events and
alarms in the background, no servers
required.
Task finishing - If your app is in
mid-task when your customer leaves it,
the app can now keep running to finish
the task.
Fast app switching - All developers
should take advantage of fast app
switching, which allows users to leave
your app and come right back to where
they were when they left - no more
having to reload the app.
Nope. The only way for your application to be "called" when it's not already open is by sending a push notification.
I would like to build an app which retrieves images from my server.
My problem is that I want it to work in the background and only when there is a 'new image' to load.
It seems like what I need is very similar to PUSH notifications:
Work in the background
Only when there is 'something new' to load.
I guess what I want became possible with the new iOS4.
Please tell me if this is feasible.
Any links for how to even start thinking about it would be great.
Thanks.
It depends on what background you mean.
If you mean that your application is running and you have some thread to get the image in the background thread, it is possible.
If you mean that your application is suspended and you still want to use PUSH notification and get the image. I am afraid that it is impossible. When your application is in the background, it has very limited amount of time that it can run to finish its current task. When that time is out, your application cannot do anything.
You can receive some push notification and local notification like GPS, server notification when your application is suspended, but you can only receive the server notification and cannot download the new image. Here is the instruction from Apple Dev documentation:
When the operating system delivers a
local or push notification and the
target application is not running in
the foreground, it presents the
notification (alert, icon badge
number, sound). If there is a
notification alert and the user taps
the action button (or moves the action
slider), the application launches and
calls the UIApplicationDelegate method
application:didFinishLaunchingWithOptions:,
passing in the local-notification
object or remote-notification payload.
If the application is running in the
foreground when the notification is
delivered, the
application:didReceiveRemoteNotification:
or
application:didReceiveLocalNotification:
method of the application delegate is
invoked.
More here