How to fetch and display the message in push notification from dynamic notification service
push: {
aps = {
alert = "My First Notification";
sound = default;
Msg = {
myData = (
{
Msg = "Awesome";
Id = 123;
Date = "Jan 18 2018";
}
);
};
};
}
As i want to display alert = "My First Notification" and Msg = "Awesome" when push notification arrives. I have no idea how to fetch and display. Please help me to solve this issue. TIA
I have tried below code
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[application registerForRemoteNotifications];
return YES;
}
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);
NSString *deviceTokenStr = [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
NSLog(@"Device Token: %@", deviceTokenStr);
}
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
NSLog(@"Failed to get token, error: %@", error);
}
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
NSLog(@"Received notification: %@", userInfo);
NSUserDefaults * loginDefaults = [NSUserDefaults standardUserDefaults];
UIApplicationState state = [[UIApplication sharedApplication] applicationState];
if (UIApplicationStateActive == state )
{
return;
}
}
I Want to display it in push notification only.