Need to increment a value while iPhone app in background

Posted on 2012-09-15
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?

Question by:newbieweb
    LVL 14

    Assisted Solution

    by:Hamidreza Vakilian
    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:

    Author Comment

    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?

    LVL 14

    Accepted Solution

    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:

    Author Closing Comment

    That ought to keep me busy for a while.

    LVL 14

    Expert Comment

    by:Hamidreza Vakilian
    You are welcome.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    iPhone 5s iCloud locked 3 23
    VMWare Workspace ONE 10 56
    Online App view platform 4 42
    Can iphone 6 casing fit into iPhone 7? 1 39
    A short article about a problem I had getting the GPS LocationListener working.
    If your app took Google’s lash recently, here are the 5 most likely reasons.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now