0

am new to ios. If we receive a notification message as "Message: @"Welcome"" then i have to show only "Welcome" in the notification of ios device. Is it possible and how to do it ?

Thanks in advance for any help.

Sakthimuthiah
  • 2,606
  • 6
  • 26
  • 41

3 Answers3

1

Whatever is sent in the payload of the push notification is displayed in the banner shown to the user. If you want to customize this message, you'll have to change what you are sending to the APNs service. See the push notification programming guide for details: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction.html#//apple_ref/doc/uid/TP40008194-CH1-SW1

badAPI
  • 122
  • 3
1

You can do this while your app is in Foreground State using remove Some specific Characters. follow (how to remove first 3 characters from nsstring?) for reference.

But if you are in Background state you can not handle payload. so whatever text was send from APNs service. it will show in iOS.

Suggestion : you can send payload like below

aps =     {
 alert =
     {
     body = Welcome;
     type = Message;
     };
 };

So you will know the type of payload and it will show only "Welcome".

Community
  • 1
  • 1
ChintaN -Maddy- Ramani
  • 5,156
  • 1
  • 27
  • 48
1

At iOS (client) side you can only program what action to be taken when user clicks on notification or when user gets remote notification . For that you have to add code in the -

-(void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo

But you will not have any control over the notification shown while your application is in background . For this you have to do string operations at server side from where you are sending the push .

V-Xtreme
  • 7,230
  • 9
  • 39
  • 79