User's chosen alert style for an iOS app - ios

How can I know the alert style of my App, as set in the app's notification settings? That is, whether the alert style is "none" or "banners" or "alerts"? I guess there should be a property to know about it in notification center. But I did not find any.
I want to adjust the number of notifications that I post based on the style -- I believe that too many alerts will interrupt the user.

Thats not possible. If you want to access this information, file a bug report about it.

Related

iOS Push Notification with Rich Content - Can I prevent a notification from being tappable?

I have a push notification with rich content.
Can I make it in such way that it is not tappable, i.e., a single tap will not open the application. It must be dragged down to rich content or 3D touched, or deleted from the notification center by swiping.
How should I indicate to the user to drag down (3D touch) in order to reveal rich content on notification?
No, a tap on a push notification will always open the notification in the app, and as far as I know there is no way in public API to override this behavior. It does appear there is a private API to get the behavior you’re looking for, as some iOS-generated (local, not push) notifications appear to do exactly what you’re asking. If you can manage to uncover that, use at your own risk should Apple find out.
Now, as for possible solutions: I would consider implementing code on your app’s delegate to respond appropriately when the notification is opened. For example, send the user to an appropriate location in the app when the app is launched from a notification…perhaps a view controller that shows the same content that would be shown as the rich notification content. I don’t know the exact use case, but the wording implies to me that if the app launches to its main interface, it could be confusing to a user.
It’s impossible for me to tell you how exactly you wish to respond to notifications, so for more on responding appropriately when the app was launched from a push notification, see the following documentation from Apple:
Determine Why Your App Was Launched
UIApplicationDelegate.application(_:willFinishLaunchingWithOptions:)
UIApplicationDelegate.application(_:didFinishLaunchingWithOptions:)
UIApplication.LaunchOptionsKey
UIApplication.LaunchOptionsKey.remoteNotification
Hopefully from that you can find a suitable solution. But if that isn’t an option, consider directly telling the user at some point to press firmly (or tap and hold, as many devices do not support 3D Touch) to view the content. You could do this during some onboarding process or, as an absolute last resort, in the notification itself.
Before proceeding down that route, though, understand that not all users know 3D Touch and/or this rich-content functionality even exists — even fewer use it regularly — and if they become confused, they may decide to clear the notification or outright disable your app’s notifications. In general, it’s also a bad idea to “teach” your user unfamiliar ways of using their device. If a user is used to tapping on notifications, as many are, they will most likely tap on your notifications. It can be tough to break that muscle memory.

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 set push subject as the title for push notification?

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

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.

local notification style coming up as banner, instead of alert

so i'm working on my first app. i'm trying to make an alarm that does OTHER STUFF. from what i've found, I want UIlocalnotification. So I've followed a few tutorials on the subject, and I have the notification fire. However, it shows as a banner which quickly disappears. I want it to look like the alarm clock alert... or any customer alert with OK, CANCEL.
Upon further reading in this forum, someone else asked the question, and if I'm reading it correctly only the USER can specify how the alert style looks.
Is this right? Can I not FORCE an alert box to popup at a specified time?
And what about UIAlertView... that looks like what I'm looking for also... can that be used to go off like an alarm clock and x time in the future?
appreciate the input, thanks
No, you cannot do that. The user is the one who decides what kind of notification he/she gets.

Resources