1

In my iOS Application, I want to hide UIAlertView when receiving push notification in didreceiveRemotenotification method. Whole page of app delegate I am not writting code for show UIAlertView. Then why does it display automatically?

 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
 [PFPush handlePush:userInfo]; 
if (application.applicationState == UIApplicationStateActive) { self.noti_json=[userInfo objectForKey:@"msg"]; 
[[NSNotificationCenter defaultCenter] postNotificationName:[userInfo objectForKey:@"title"] object:self];
 } } 

Thanks in Advance.

Edit (Adding code for my didReceiveRemoteNotification:):

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{ 
   [PFPush handlePush:userInfo]; 
   if (application.applicationState == UIApplicationStateActive) 
   { 
      self.noti_json=[userInfo objectForKey:@"msg"];   
      [[NSNotificationCenter defaultCenter] postNotificationName:[userInfo objectForKey:@"title"] object:self]; 
    } 
 } 
Unheilig
  • 16,196
  • 193
  • 68
  • 98
Monika Patel
  • 2,287
  • 3
  • 20
  • 45
  • post your didreceiveRemotenotification method implementation – Muhammad Adnan Jun 05 '15 at 05:26
  • - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { [PFPush handlePush:userInfo]; if (application.applicationState == UIApplicationStateActive) { self.noti_json=[userInfo objectForKey:@"msg"]; [[NSNotificationCenter defaultCenter] postNotificationName:[userInfo objectForKey:@"title"] object:self]; } } – Monika Patel Jun 05 '15 at 05:27

2 Answers2

1

Remove the line [PFPush handlePush:userInfo];

and show your own alert only if the type is not the one you wanna avoid.

UserInfo must have some identifier or type of notification so that you can handle type specific notifications accordingly.

Handle Push

Edit

Or Simply use below line

if(![[userInfo objectForKey:@"type"] isEqualToString:@"typeName"]){
 [PFPush handlePush:userInfo]; 
}
Muhammad Adnan
  • 2,668
  • 15
  • 27
0

If you're receiving alerts for Push Notifications it can be due to having the Alerts enabled in settings for your app.

David van Dugteren
  • 3,879
  • 9
  • 33
  • 48
  • if notification disable from application setting then , i am not able to any notification related to my application. i want to receive notification without displaying UIAlertview – Monika Patel Jun 05 '15 at 05:25
  • my code is : - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { [PFPush handlePush:userInfo]; if (application.applicationState == UIApplicationStateActive) { self.noti_json=[userInfo objectForKey:@"msg"]; [[NSNotificationCenter defaultCenter] postNotificationName:[userInfo objectForKey:@"title"] object:self]; } } – Monika Patel Jun 05 '15 at 05:27