7

I'm using storyboard for my sample project. The architecture is Login View Controller and Home PageView controller. User clicks on button in Home PageView controller to start local notification.

-(IBAction)startLocalNotification {  // Bind this method to UIButton action
    NSLog(@"startLocalNotification");

    UILocalNotification *notification = [[UILocalNotification alloc] init];
    notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:7];
    notification.alertBody = @"This is local notification!";
    notification.timeZone = [NSTimeZone defaultTimeZone];
    notification.soundName = UILocalNotificationDefaultSoundName;
    notification.applicationIconBadgeNumber = 10;

    [[UIApplication sharedApplication] scheduleLocalNotification:notification];
}

This code goes in AppDelegate file :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){

        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
    }

    [launchOptions valueForKey:UIApplicationLaunchOptionsLocalNotificationKey];
    // Override point for customization after application launch.

    return YES;
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
 [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
     NSLog(@"didReceiveLocalNotification");
}

Now after pushing app to background state I'm getting below message in console but local notification is working fine as expected.

Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.

What this message is related to?

Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
  • 1
    I *think* it must be related to the screenshot that is formed when entering the background. Unfortunately I have no idea whether this a serious issue or just a bit of information that I can choose to ignore. I'd be interested to know if you made any progress or have any information on whether I need be bothered about it. – button Mar 09 '15 at 19:29
  • Have you resolved this issue? – FedeH Jul 15 '15 at 19:28

1 Answers1

3

I have what I believe could just about stand up as an 'answer'... And that is that there's almost certainly nothing wrong, but maybe a problem with iOS (8.1.3/8.2). As far as I can tell, it's innocuous.

I played around with this and found that it was related to UITextField/Keyboard.

So a single view app with just a text field, follow the steps below (only tried on iPad):

  1. Build and run
  2. Put focus in text field
  3. Close keyboard (it should have opened)
  4. Click home button (app enters background)
  5. Return to app
  6. Click home button (app enters background)
  7. Observe log output.

Here's a sample project: https://github.com/duttski/TestForStrangeSnapshotMessage .

Filed as a bug and trying to get some information through the dev forums too.

UPDATE: I think this may be fixed in later versions. But I haven't tested it. After speaking on the dev forums I was told that this isn't something to worry about.

button
  • 666
  • 6
  • 14
  • Your take could not be correlated with exact problem. – Jayprakash Dubey Mar 11 '15 at 06:26
  • Could you clarify the problem? -- you asked what the meaning of this message was, but said everything was working. The upshot of the above is that presumably it doesn't doesn't have any meaning in relation to your project. That might be wrong, but the demonstration app above at least shows that we can receive the message in even the most basic of circumstances. – button Mar 11 '15 at 09:28
  • @button, I am facing the same issue (ios 9.3, swift 2.0). Other SO posts I found on this issue were talking about ImagePickerController, which I was not using. Spent almost 2 days to arrive at the exact same steps you have given here. Kindly update here once they respond to your bug report or if you come across more info on this. – programmist Mar 28 '16 at 05:48
  • @mpathi last message in March '15 was asking me to test on an 8.3 beta build. I am not currently working on iOS projects so not in a position to verify if it is the same problem I'm afraid. There was no indication that anything had changed. Seems the repo above has gone but I could probably find it again if it helps (just a text field on a view from what I remember!). – button Mar 29 '16 at 08:26
  • I also have the same strange warning message although i don't use the camera or a ImagePickerController. I can see this warning message after orientation changes (Landscape <-> Portrait). I use the latest versions: Xcode 8.3 with Swift 3 on iOS 10.3. Seems this issue has not been solved yet. – cylov Jul 06 '17 at 12:05