I need to show a universal custom view whenever i received a notification in a active app.
I have created a view , but i am not getting how to show that!
Can anyone help me out.
Asked
Active
Viewed 47 times
0

Niharika
- 1,188
- 15
- 37
-
check this http://stackoverflow.com/questions/2191594/send-and-receive-messages-through-nsnotificationcenter-in-objective-c .if any problem than tell me – Jigar Mar 15 '17 at 07:42
-
Accept answer which helps you – vivek bhoraniya Jun 28 '17 at 12:12
2 Answers
0
You have to handle the notification in the AppDelegate
methods (usually application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
) and launch the view in the form it can be shown in any screen of your app.
You can read the docs for UIApplicationDelegate
here, section Responding to Notifications and Events.

emenegro
- 6,901
- 10
- 45
- 68
0
You will be receiving the push notification in AppDelegate's application(_:didReceiveRemoteNotification:fetchCompletionHandler:) from here you can handle.
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler
{
// 1. You can call your universal view from here
OR
// 2. You can post this local notification with information
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:myObject forKey:@"info"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"showNotification"
object:nil
userInfo:userInfo];
}
For 2nd Option, you will need add observer and receiving method:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveNotification:)
name:@"showNotification"
object:nil];
-(void)receiveNotification:(NSNotification *)notification {
// call your view
}

nikdange_me
- 2,949
- 2
- 16
- 24