Question

I am receiving push notification in that payload message i am receiving one URL with message as push notification. but i dont want to show URL to user i want to show only message to user. is it possible from ios side.

Was it helpful?

Solution

If your are using url as a separate key in aps then its possible you can display alert only as a message, otherwise any message can't be modify message in background.

 "aps": {
        "alert": "alert!",
        "sound": "default",
        "URL"  : "your url"
        }

OTHER TIPS

yes, its possible but it also depend on how you have created your payload but its simple as you create your payload with your link and message, receive at your delegate

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)pushChatObject {
      // get the message value and NSLog is or set to UIAlert or in NSString
      (pushChatObject)[@"Message"];
}

You can, but you shouldn't, because

Delivery of notifications is a “best effort”, not guaranteed. It is not intended to deliver data to your app, only to notify the user that there is new data available. (c) Apple

Specify the notification message as

{
    "aps": {
        "alert": "alert!",
        "sound": "default"
    },
    "URL": "http://apple.com"
}

When you receive the notification in the app just check for your param in the notification dictionary:

// Place this method to AppDelegate.m
- (void)application:(UIApplication *)application didReceiveRemoteNotification:
                                         (NSDictionary *)notification {      
    if ([notification objectForKey:@"URL"]) {
        NSString *url = [[notification objectForKey:@"URL"] stringValue];
    }
}

Check this section of Apple's Local and Push Notification Programming Guide for more info

I think in this case you can use Child properties of the alert property, you use 1 argument as a alert and another argument as a url, like: "aps": { "alert" : { "loc-key" : "ALERT", "loc-args" : [ "Your alert message", "Your url"] }, "sound": "default" }

When the device receives the notification, it uses "ALERT" as a key to look up the associated string value in the Localizable.strings file in the .lproj directory for the current language. Assuming the current localization has an Localizable.strings entry such as this: "ALERT" = "%@";

And later on you can get your url using aps NSDictionary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top