1

for modification purpose of notification we used notification service extension but i am not able to find out some logs in my xcode console.

 (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];

// Modify the notification content here...


NSLog(@"tesrrrr");(Missing in console)


self.bestAttemptContent.title = [NSString stringWithFormat:self.getfuction, self.bestAttemptContent.title];
self.bestAttemptContent.body = [NSString stringWithFormat:@"%@[ body  added Manually ", self.bestAttemptContent.body];

self.contentHandler(self.bestAttemptContent);

-(NSString*)getfuction {

NSLog(@"xyz");
NSURL *url = [NSURL URLWithString:@"http://jsonplaceholder.typicode.com/posts/1"];
NSData *data = [NSData dataWithContentsOfURL:url];
NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"ret=%@", ret);(Still Missing in console)
return ret ;

}

Nslog are not coming in Xcode Console .

Same code put in Appdelegate.m working fine

SANTOSH
  • 183
  • 1
  • 15

1 Answers1

0
Please try to run your application with UNNotificationServiceExtension target that you have created for Rich Notifications.

Don't forgot to add "mutable-content" in payload and your "aps" payload should be like this:

{
    "aps": {
        "alert": {
            "body": "Het gaat over 15 minuten regenen in Alkmaar",
            "title": "Buienalert"
        },
        "mutable-content": 1
    },
    "attachment-url": "https://api.buienradar.nl/Image/1.0/RadarMapNL"
}

Hope, it would help you.
Inder Jagdeo
  • 229
  • 2
  • 9
  • thanks for reply ,,i tried to run with Notification service extension as target but at that moment Not modified coming(means doesnt its doesnt run Notificatiionservice.m files) ..My main concern about NSLog not coming – SANTOSH Jul 21 '17 at 06:52
  • @SANTOSH, When you run application with notification service extension target then XCODE doesn't log anything in your application target because you are running another target. That's why, you can log in notification service extension protocol. – Inder Jagdeo Jul 21 '17 at 07:57
  • @SANTOSH, set your notification service extension target less than project deployment target. – Inder Jagdeo Jul 21 '17 at 08:03