2017-03-01 1 views
-1

Ich erhalte eine Liste der Push-Benachrichtigung. Wenn der Benutzer eine Benachrichtigung wählt mag ich aus, dass notification.from die Liste der MeldungenErhalten Sie APNS Payload-Inhalte während der Auswahl der empfangenen Push-Benachrichtigung

Vielen Dank im Voraus

+0

was hast du probiert? – GeneCode

+0

@Anbu.Karthik Ich habe meinen Code veröffentlicht bitte teilen Sie Ihre Gedanken –

+0

@GeneCode Ich habe meinen Code veröffentlicht teilen Sie Ihre Gedanken –

Antwort

-1
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{ 
    NSLog(@"Notification Received .. Dictionary %@",userInfo); 
    NSString *user_TYP = [[NSUserDefaults standardUserDefaults]valueForKey:@"User_TYPE_LOG"]; 
    NSLog(@"Usr type == %@",user_TYP); 

    // all the data required is present in your info dictionary 

    id data1 = userInfo[@"key1"]; // user your data_type instead of id 
    id data2 = userInfo[@"key2"]; 

    if(received data == x && [user_TYP isEqualToString:@"type1"]) 
     do_something; 
    else 
     do_something_else; 

} 
+0

es tut funktioniert nicht in ios 10 –

+0

@ Anbu.Karthik Es funktioniert –

0

für Swift ausgewählt, um die Daten zu erhalten: Die Meldung Daten werden in application:didReceiveRemoteNotification: Ihre App geliefert. Wenn Sie es in applicationDidBecomeActive: verarbeiten möchten, sollten Sie es in application:didReceiveRemoteNotification: speichern und in applicationDidBecomeActive erneut lesen.

Wenn Ihre App im Vordergrund in der Anwendung :didReceiveRemoteNotification: ist, können Sie UIApplication.sharedApplication().applicationState abfragen, um herauszufinden, ob Ihre App bereits im Vordergrund ist. Wenn dies der Fall ist, dann verarbeiten Sie die Benachrichtigung sofort.

wenn App per Push-Benachrichtigung gestartet ist, können Sie auch Daten überprüfen eindrücken

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
      // app was launched from push notification, handling it 
    let remoteNotification: NSDictionary! = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary 
    if (remoteNotification != nil) { 

    } 
} 

für Objective C: App-Status abfragen Sie -[UIApplication applicationState] abfragen können, um herauszufinden, ob Ihre App bereits in der ist Vordergrund und wenn App von Push-Anwendung gestartet:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    //Check for options 
    if (launchOptions != nil) 
    { 
     //Store the data from the push. 
     dUserInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; 
     if (dUserInfo != nil) 
     { 
      //Do whatever you need 
     } 
    } 

    return YES; 
} 
+0

Danke werde ich versuchen –

+0

Vielen Dank, dass dies funktioniert :) –

0

Was habe ich ist

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{ 
NSLog(@"Notification Received .. Dictionary %@",userInfo); 
NSString *user_TYP = [[NSUserDefaults standardUserDefaults]valueForKey:@"User_TYPE_LOG"]; 
NSLog(@"Usr type == %@",user_TYP); 
if ([user_TYP isEqualToString:@"type1"]) 
    { 
     //  VW_User_NOTific *VW_SER = [[VW_User_NOTific alloc]initWithNibName:@"VW_User_NOTific" bundle:nil]; 
     VW_User_NOTific *listingVC = [[VW_User_NOTific alloc] init]; 
     [(UINavigationController *)self.window.rootViewController pushViewController:listingVC animated:YES]; 
    } 
    else 
    { 
     VW_JS_Notific *listingVC = [[VW_JS_Notific alloc] init]; 
     [(UINavigationController *)self.window.rootViewController pushViewController:listingVC animated:YES]; 

    } 
} 
Verwandte Themen