Push Notification soll bei Swipe die entsprechende News öffnen

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Push Notification soll bei Swipe die entsprechende News öffnen

    Hallo Community...

    Wir haben es geschafft, und unsere App empfängt nun Push Nachrichten. Jetzt gibt es nur noch eine kleine Sache:

    Wenn wir im Sperrbildschirm die PN wegswipen, dann soll sich nicht einfach nur die App, sondern der dazugehörige Newseintrag in der App öffnen. Wenn ich den unten stehenden Link richtig verstehe, dann muss das auf der Serverseite erledigt werden.

    stackoverflow.com/questions/10…ew-from-push-notification


    Allerdings muss ich gestehen, dass ich keinen Plan habe, was ich da nun mitgeben muss. Bzw. ist es so, dass der Pushserver extern läuft, und ich dem Admin da mitteilen müsste, was er mitgeben muss.

    Könnte mir da vielleicht jemand auf die Sprünge helfen?
  • Die beiden Einträge habe ich exakt so drin, aber da öffnet sich einfach nur die App... :(

    Hier mal mein Code:

    Quellcode

    1. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
    2. //NSLog(@"Eine Nachricht ist angekommen, während die App aktiv ist");
    3. NSString* alert = [[userInfo objectForKey:@"aps"] objectForKey:@"id"];
    4. NSLog(@"Nachricht: %@", alert);
    5. //This is to inform about new messages when the app is active
    6. //UIApplicationState state = [[UIApplication sharedApplication] applicationState];
    7. //if (state == UIApplicationStateActive) {
    8. // UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Neuer Artikel" message:@"Nachricht" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    9. // [alertView show];
    10. // }
    11. }
    12. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    13. NSLog(@"Device Token=%@", deviceToken);
    14. NSUInteger theCount = [deviceToken length];
    15. NSMutableString *theString = [NSMutableString stringWithCapacity:2 * theCount];
    16. unsigned char const *theBytes = [deviceToken bytes];
    17. for(NSUInteger i = 0; i < theCount; ++i) {
    18. [theString appendFormat:@"%2.2x", theBytes[i]];
    19. }
    20. NSString* url = [NSString stringWithFormat:@"http://byte-welt.net:8080/PushServer/register?devicetype=4&appkey=23e409isaeroakse23sae0&deviceid=%@&devicekey=%@",theString,theString];
    21. NSLog(@"APNS URL : %@",url);
    22. NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
    23. [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *urlResponse, NSData *data, NSError *error) {
    24. if (error) {
    25. NSLog(@"Error: %@", error);
    26. }
    27. }];
    28. }
    29. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
    30. NSLog(@"Error bei der Registrierung");
    31. }
    32. //This is the end of the methods for push notifications
    33. - (id)init {
    34. self = [super init];
    35. if (self) {
    36. }
    37. return self;
    38. }
    Alles anzeigen


    Und:

    Quellcode

    1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    2. self.window.frame = [[UIScreen mainScreen] bounds];
    3. [self setApplicationDefaults];
    4. [[UIApplication sharedApplication] setStatusBarHidden:NO];
    5. //This is the start of the push notification settings
    6. [self.window makeKeyAndVisible];
    7. //This is to show an UIAlertView when the app receives push notifications in inactive state (Only for testing purposes)
    8. //if ([launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
    9. // NSString* alert = [[[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey] objectForKey:@"aps"] objectforkey:@"alert"];
    10. // UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Neuer Artikel" message:alert delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    11. // [alertView show];
    12. // }
    13. // Let the device know we want to receive push notifications
    14. [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
    15. (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    Alles anzeigen

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von Thaddel ()

  • Du hast ja alle "Test-Instanzen" also NSLog / Alert usw. auskommentiert.

    Quellcode

    1. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{ //NSLog(@"Eine Nachricht ist angekommen, während die App aktiv ist");


    Wenn du NSLog wieder aktivierst, bekommst du dann die Nachricht im Log wenn du ne Push Benachrichtigung schickst?
  • Habe das jetzt wieder aktiviert, und bekomme in der Konsole diese Meldung, wenn ich mir per PushMeBaby eine Nachricht sende:

    2012-10-29 13:55:21.249 IBC[1625:907] Eine Nachricht ist angekommen, während die App aktiv ist
    2012-10-29 13:55:21.250 IBC[1625:907] Nachricht: (null)

    Ich kann das im Moment leider nicht anders testen, da die Push Notifications vom RSS-Feed der News kommen.
  • Ich bin da blutiger Anfänger... :(

    Wie müsste ich das denn machen? Das ist eigentlich der letzte Punkt, den ich noch hinbekommen müsste, dann wäre Push Notification komplett... :)

    Die News selbst wird in DetailNews bzw. DetailViewController angezeigt...
  • Was hast du denn probiert?
    Hast du versucht herauszufinden wie man aus einer Methode einen View aufruft?

    Also im Grunde ist es ja nichts anderes, als wenn du den View über einen Button öffnest, z.B. so:

    stackoverflow.com/questions/65…-button-is-pressed-in-ios


    Du musst dich natürlich schon in grundlegende Dinge einlesen, bzw. ausprobieren. Eigentlich ist jede dieser Fragen schonmal beantwortet worden, in der Regel auf Englisch und evtl. etwas anders formuliert. Google hilft da super.