Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Need to increment a value while iPhone app in background

Posted on 2012-09-15
5
Medium Priority
?
1,743 Views
Last Modified: 2016-02-10
I am new to iPhone app and Objective-C development.  What I need is that while the app is in the background, I need for it to show a value in the upper right corner, just like when a phone has updates ready.  Or, when I have emails, it show me mow many it has.

Is this a push notification which results in the counter being increased?

I do not plan to have a server, so is this even possible?

Thanks!
0
Comment
Question by:newbieweb
  • 3
  • 2
5 Comments
 
LVL 15

Assisted Solution

by:Hamidreza Vakilian
Hamidreza Vakilian earned 2000 total points
ID: 38403684
Backgrounding.... the gloomy part of the iOS!
In general there is no tenacious backgrounding support in iOS. All applications gets terminated usually 10 minutes after exiting (there exists an exception here for VOIP, GPS aware and audio apps but even when the user opens a big application like those from Gameloft's, iOS will purge inactive applications memory therefore those so-called background apps will be killed).

If you want to change the badge number even when your app is not opened; your solution is to use push notifications. With push notification which must be created and sent from a server, you can define the badge number for your app remotely. But as I mentioned you need to dedicate a server for that. Therefore it's not possible to accomplish it without having a server.

A good tutorial for push notifications if you want:
http://mobiforge.com/developing/story/programming-apple-push-notification-services
0
 

Author Comment

by:newbieweb
ID: 38403775
So, Push Notification is the only way to increment that index.  I am talking about the little red circle upper right corner of the icon.  Does that specifically represent the number of push notification in the queue?

And is PN the only way to index that number?

Thanks.
0
 
LVL 15

Accepted Solution

by:
Hamidreza Vakilian earned 2000 total points
ID: 38403811
It does not necessarily show the PN numbers.
You can set the badge number this way:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];

You may notice that you can use local notifications since ios 4 to fire at specified time even when your app is not running. But there's no support for checking number of news or performing some task in bachground. You can just schedule a notification this way.
UILocalNotification tutorial:
http://www.icodeblog.com/tag/uilocalnotification/
0
 

Author Closing Comment

by:newbieweb
ID: 38403834
That ought to keep me busy for a while.


Thanks!
0
 
LVL 15

Expert Comment

by:Hamidreza Vakilian
ID: 38403924
You are welcome.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brand new malware strain was recently discovered by security researchers at Palo Alto Networks dubbed “AceDeceiver.” This new strain of iOS malware can successfully infect non-jailbroken devices and jailbroken devices alike.
If your app took Google’s lash recently, here are the 5 most likely reasons.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question