How to set push subject as the title for push notification?
Asked Answered
B

4

8

Is there any possibilities of setting push subject as the title in push notification? I'm getting app name as the subject and description is same as given in the push. I want to change the title of the push.
Is this possible in iOS? I hope it is possible in android.

Beals answered 14/5, 2014 at 8:14 Comment(7)
Sorry to disappoint you, but this is not possible in ios. The title of your notification will always be your app name.Zennie
May i know what is the reason behind that?Beals
There is no API function to do that. As for the reason... you will have to ask Apple about it ;)Zennie
ok @Argent. So if this is the reason i can able to convenience the client by saying your opinion to them. Thank you.Beals
This is the sad truth. This will be hard to understand for some clients (I had conversations about this topic myself) because there is no real reason for this behavior.. but there is no way around it.Zennie
This has changed as of iOS 8.4, the title key inside of the alert dictionary now shows up instead of the app name.Synecious
It is possible now.. Please check this tutorial avanderlee.com/ios-10/rich-notifications-ios-10Gowan
E
20

I just tested this on an iPhone 6s running iOS 9.1, and here's what I found: If the title field is provided as part of the alert dictionary, the notification on the lock screen will still show the bundle name. However, when viewing the same notification in Notification Center (accessed by swiping down from the top edge), the title is used in place of the app/bundle name.

When no title field is provided as part of the alert dictionary, the bundle name is displayed in both the lock screen and the Notification Center.

Ewall answered 1/12, 2015 at 20:42 Comment(0)
S
17

As of 2015, Apple has started using a title attribute but only seems to use when displaying a notification on the Apple Watch.

The title string used in the short look provides a brief indication of the intent of the notification. For local notifications, you specify this string using the alertTitle property of the UILocalNotification object. For remote notifications, add the title key to the alert dictionary inside the payload

This might indicate that it will be used also on the iPhone later on.

Source: https://developer.apple.com/library/content/documentation/General/Conceptual/WatchKitProgrammingGuide/BasicSupport.html

Here's an example JSON payload: https://gist.github.com/edwardmp/2295364f068b24084e67561c8e5c2944

Edit: As of iOS 9 this started working on iPhone and iPad as well :) I do note that this appears to only be displayed in the notification center and not on the lock screen.

Syndesis answered 14/2, 2015 at 22:41 Comment(7)
As of iOS 8.4 the iPhone now displays the title instead of the app name where it is being used.Synecious
@john Can you elaborate? As far as I can tell from testing, this still is not available on the iPhone.Respondent
@ninehundredt you can set the title and body separately in the json hash, and on the lock screen it will show a separate title than the App Name.Synecious
I can concur this now works on iPhone as well, in the way @Synecious describesSyndesis
@Synecious Thanks for responding. Any chance you could post a link with example json in a gist? I tried adding the key and value per your instructions, and nothing would show up. Not sure what I'm doing wrong.Respondent
@ninehundredt don't think you still need this but I added an example payload in the post.Syndesis
@Syndesis Very good finding. Tried the sample son payload, it works.Funnelform
R
10

You can't change the title. It's always the application name.

Suppose you are playing chess with your friend online. While you are in the chess app, your friend’s moves appear on the board right away. When you switch to another app—for example, to read email while your friend decides where to move—the app needs a way to notify you when your friend moves. This is a perfect use case for a push notification—something changed outside of the app that is of interest to the user.

The provider for the chess application learns about this move and, seeing that the chess application on your device is no longer connected, sends a push notification to Apple Push Notification service (APNs). Almost immediately, your device—or more precisely, the operating system on your device—receives the notification over the Wi-Fi or cellular connection from APNs. Because your chess application is not currently running, iOS displays an alert similar to Figure 1-1. The message consists of the application name, a short message, and (in this case) two buttons: Close and View. The button on the right is called the action button and its default title is “View”. An application can customize the title of the action button and can internationalize the button title and the message so that they are in the user’s preferred language.

You can refer your client to the official APNS docs to convince them that's the way it is.

Rosanne answered 14/5, 2014 at 14:45 Comment(1)
Thank you. Got enough description to explain the client.Beals
R
3

Yes, you can add a title property since iOS 8.2.

A short string describing the purpose of the notification. Apple Watch displays this string as part of the notification interface. This string is displayed only briefly and should be crafted so that it can be understood quickly. This key was added in iOS 8.2.

Check the Apple Document - The Remote Notification Payload

Rodmann answered 18/2, 2016 at 9:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.