1

I am implementing Silent notification in Objective c Code in ios 11. Using FCM Notification by adding this method. What is Silent Push Notification? When does the device receive it?

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
{

   //Success
    handler(UIBackgroundFetchResultNewData);
}

and paylod is :

    {
    "aps" = {
        "content-available" : 1,
        "sound" : ""
    };
    // You can add custom key-value pair here...
}

didReceiveRemoteNotification method call when notification recived But my question is why banner is visible when silent notification receive. How to restrict notification banner.

Shahbaz Akram
  • 1,598
  • 3
  • 28
  • 45
  • 1
    Possible duplicate of [What is difference between remote notification and silent notification in iOS?](https://stackoverflow.com/questions/42275060/what-is-difference-between-remote-notification-and-silent-notification-in-ios) – Harshal Valanda Jun 28 '18 at 04:34
  • 1
    can you try removing `"sound" : ""` from your payload? – mfaani Jun 28 '18 at 04:42
  • Refer this: https://stackoverflow.com/questions/41345889/its-possible-to-change-push-notification-message-before-display-on-device-from – Chandresh Kachariya Jun 28 '18 at 05:25

2 Answers2

1

I R&D on it. finally i got link form youtube https://www.youtube.com/watch?v=Xde7ns5w9LM . i remove extra keys from payload like alert title etc just add following and issue resolve.

"aps" = {
    "content-available" : 1,
    "sound" : ""
};
Shahbaz Akram
  • 1,598
  • 3
  • 28
  • 45
1

Remove extra keys from aps array and payload should be like this.

"aps" = {
    "content-available" : 1
};
Shahzad Nasir
  • 168
  • 1
  • 2
  • 11