How to set push subject as the title for push notification? - ios

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.

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.

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.

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.

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

Related

Detect when a notification appears (from another application) to change my layout

Do I want to know if it's possible to detect when a notification from another application is over my app? For example, when the user receives an SMS or Messenger message. Detect the fact that a notification is present on the screen. I don't want the content of the message.
It's an example, It can be a notification for whatever. Because, when a notification is visible, my player's lost because a part of the UI is under the notification. So, if I know when a notification is visible I can change the layout.
It's not possible to handle notifications from other apps. It would be a huge privacy violation.

How to transfer user from Apple Watch Notification to Apple Watch App?

When a Push Notification is displayed on the Apple Watch, the only possibility to open the Apple Watch App is to tap the App icon in the upper left corner.
Now, as I´m reviewing our tracking data, no user seems to know this.
How can I install another tap area in the Notification View which transfers the user in the Watch App?
The first thing to understand is that notifications aren't specific to either the iPhone or the Apple Watch. They're the same old notifications we've been dealing with for years, and nothing has changed. That means that there's no such thing as an "Apple Watch-specific notification" or an "iPhone-only notification." iOS decides where to route a notification based on its own heuristics. There is no way to programmatically control which device receives an alert.
That said, stk is correct that you will have to add actions to a category that you set for your notification. The Notification Essentials section of the Apple Watch Programming Guide has some sample code.
Because there is no such thing as an iPhone- or Watch-specific notification, you're correct that you will see these actions on both devices. So, you'll have to do something meaningful on both platforms. This makes sense, because iOS decides where to send the notification, so it should be handled appropriately wherever it's sent.

Apple Watch: dynamic Long Look not shown, when push opened from Notification Center

I implemented a custom dynamic Long Look for push notifications on the Apple Watch. This dynamic long look is shown correctly, when I immediately raise my arm after receiving a push notification. However, if I respond later, and tap on the push notification from within Notification Center on the Watch, only the static long look is shown.
Is this normal behavior or am I doing something wrong? How are your dynamic long looks behaving?
For clarity here are the steps to reproduce.
This will bring up the dynamic long look:
I receive a push notification on the Watch
I immediately raise my arm to see the push
But this will only bring up the static long look:
I receive a push notification on the Watch
Ignore it at first. After one minute activate the Watch
Drag down from top of the Watch face to bring up Notification Center
Tap on the ignored push
I suspect all notifications that are accessed through the notifications center of the watch are by default static.
I can't find any documentation to confirm this though. Would be a major bummer if that's the case.
I also experience the same problem and it is pretty frustrating because like Sohail my action buttons refer to the dynamic long look notification content. I dont know if I get the apple documentation right here but the following lines sound like the proof to me that apple won´t show your dynamic long look notifications from the notification center:
Use the static notification interface to define a simple version of your custom notification interface. The purpose of a static interface is to provide a fallback interface in the event that your WatchKit extension is unable to configure the dynamic interface in a timely manner. The interface is also displayed in Notification Center.
In the first place I thought this means the notification center just shows the static notification interface in it´s "main table view" but this is not the case. The notification center itself only shows the notification alert message and not the whole interface. So I think what they mean in the documentation is: "The interface is also displayed when opening notifications from the notification center"

How to configure local notification for the Apple Watch

I just had my IOS (8.2) app update rejected because local notification were not appearing on the Apple Watch.
Since local notifications cannot be tested on the simulator, and the watch hasn't been released yet, it's a bit difficult to tell exactly what is wrong.
I suspect it has to do with setting the alertTitle property of the UILocalNotification object, as mentioned in the Apple Watch Programming Guide which I wasn't doing.
The reason I wasn't setting this is because the alertTitle and alertBody properties seem to be treated differently in Notification Centre and the Watch.
For example, if I want the Watch to show "History in 2 minutes.", then according to the programming guide, I need to set the alertTitle.
However, for the iPhone app, I need to set the alertBody so that Notification Alerts display as shown (If I only set title, and no alertBody, then the notification alert is not shown):
Text from alertBody:
But, if I also set the alertTitle to the same text, (so that it appear on the Watch) then in Notification centre, the text is shown twice, i.e. the title and the body, e.g.:
Text from alertTitle and alertBody
Also, if I don't set the alertTitle, then the main notification screen shows the app name, which is rather annoying too. e,g,:
Text from app name and alertBody - no alertTitle set:
So, is there any combination of setting alertTitle and alertBody that will work for Notification Alerts, Notification Centre and the Watch?
BTW: I've just removed the notification screen shots and description from the app and re-submitted. I'll add local notifications back once I can test in the simulator (If that ever happens), or I get a watch (if that ever happens too!).
It makes sense when setting the alert title and the alert body to different texts. According to the Apple docs for the alert title of UILocalNotification:
Title strings should be short, usually only a couple of words
describing the reason for the notification. Apple Watch displays the
title string as part of the short look notification interface, which
has limited space.
So, in my app I set the title and the body to different texts.
This appears when the notification pops up:
And this is the text in the notification center, where both the title and the body are displayed:
I understand the docs so that only the title will be displayed in the short notificaton on the Apple Watch.
I think your app got rejected due to not setting a title for the notification.

How can I edit the pairing alert view

I am developing an iOS 6 app that pairs with a custom BLE device.
When the user wants to pair, an alert message appears (directly form core bluetooth I guess) and the user can either push "Pair" or "Cancel".
However the title and body of the alert message are empty showing "PAIRING_TITLE" and "PAIRING_BODY".
How can I write a specific content for these two variables? Any idea?
As you guessed, that alert view is shown by the system and cannot be customized. I suppose it is the simulator that is causing those messages to be shown instead of some meaningful text. This can never happen on an actual device. Recommendation from Apple is not to use the simulator for development of BLE stuff. It is very likely that it won't be possible in the near future anyway.

Resources