Sakthimuthiah
Sakthimuthiah

Reputation: 2636

How to change notification message in ios by objective c code?

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.

Upvotes: 0

Views: 1121

Answers (3)

ChintaN -Maddy- Ramani
ChintaN -Maddy- Ramani

Reputation: 5164

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".

Upvotes: 1

V-Xtreme
V-Xtreme

Reputation: 7333

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 .

Upvotes: 1

badAPI
badAPI

Reputation: 122

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

Upvotes: 1

Related Questions