Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8587047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:28:15+00:00 2026-06-11T22:28:15+00:00

I am new to objective-c, xcode and app dev so please bear this in

  • 0

I am new to objective-c, xcode and app dev so please bear this in mind.

I can send a push notification via APNS to my emerging app. I can see the JSON message and can NSSLog it.

Payload: {
    aps = {
        alert = {
            "action-loc-key" = Reveal;
            body = "Hi Aleem, we have a new special offer just for you!";
        };
        badge = 70;
        sound = default;
    };

    myCMD = {
        "update_colour" = red;
    };
}

All good so far. However, I need to be able to act upon the push message by taking an action. For example, I want to be able to extract the update_colour and use the value red to change the background colour of a label on my one and only controller to red.

My problem is that I cannot reference my label from my appdelegate.m. Therefore I can’t update the background colour or even call a method on the controller to do it either.

Any help with this would be really appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:28:16+00:00Added an answer on June 11, 2026 at 10:28 pm

    In your delegate add:

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo;
    

    Then when a push notification is received whilst the application is running/ a user opens a push notification you can access the notifications payload and act upon it, you could then send a notification to your view controller.

    Add the Observer, in your view:

    [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(backgroundChanged:)
                                             name:@"ChangeBackground"
                                           object:nil];
    

    Add handle it.

    - (void)backgroundChanged:(NSNotification *)notification {
        NSDictionary *dict = [notification userInfo];
    
        NSLog(@"%@" [[dict valueForKey:@"myCMD"] valueForKey:@"background-colour"]);
    
        label.backgroundColor = [UIColor xxx];
    }
    

    Then in the delegate:

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
        if([userInfo valueForKey:@"myCMD"]) {
                NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
            [notificationCenter postNotificationName:@"ChangeBackground"
                                        object:nil
                                        userInfo:userInfo];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Xcode and objective C programming.Please help me to resolve the
I'm new to objective-C so, bear with me. I started with the Universal App
I am new to objective-C and Xcode and I am trying to pass an
I'm new to xcode and objective-c. I also decided to add unit (logic) tests
I'm new to developing with xCode and Objective C, and I have a simple
Hey there, I'm a designer thats really new to programming with xcode or Objective-C
I am fairly new to XCode and the Objective-C language. When I am instantiating
I am fairly new to XCode and the Objective-C language. When I am instantiating
I am in the process of building my first iPhone app (xCode,objective-c) which has
im new with objective-c. I have problem with memory leaking when developing iphone app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.