Reputation: 5181
In my (iPhone) application, i am keep track of how long application is active. If it's exceeds specific value (say 15 mins), login view will be present to user with alert view. This behavior is similar if application is in the background for too long. Then Alert view will present to the user when the app become active again.
But the problem is when application is in the background for very long and application become active again AlertView is not showing to the user. I am using NSNotifications for notify whether session is timed out.
Basic flow is like this
Start the App -> Put the App into Background -> applicationDidBecomeActive: -> check whether session has timed out -> Show Login View -> Post Logout notification
Receiver will show the alertview. I put recieving logic inside app delegate as well as loginview. But in both scenarios alertview will not show if it's in background for long time.
My Question is Can I recieve a notification with some delay? I want to recieve it after Login view appears.
Upvotes: 0
Views: 238
Reputation: 8947
receive notification is the delegate method of your app and it will receive where it is implemented. but you may set different flags to check wheather application is active or not.
for example in application will resigactive
set a flag isActive = no;
and in receive notification check isActive set a flag hasReceivedNotification= YES; and store data to somewhere
and in application did become active check whether aplication was active and is received remote notification set a third flag shouldShowAlertOnLoginView = YES; // the notification data is in case to show
and at loginview check appDelegate.shouldShowAlertOnLoginView == YES
then show alert with data
Upvotes: 1