Skip to content

Commit

Permalink
[TIMOB-26103] iOS 12: Expose new UserNotifications API's (#10091)
Browse files Browse the repository at this point in the history
* [TIMOB-26103] First stage of adding the new UserNotifications API's

* Fix method access for two methods, fix 7.2.0 -> 7.3.0, fix docs (#10093)

* Add docs

* Update docs, fix typo

* Add Ti.App.iOS unit tests

* Update ti.app.ios.searchquery.test.js

* Update ti.app.ios.test.js

* feat: expose "threadIdentifier", fix: "timezone" property in notifications

* Some final improvements
  • Loading branch information
hansemannn authored and sgtcoolguy committed Aug 27, 2018
1 parent 89c9bc1 commit c352cb8
Show file tree
Hide file tree
Showing 10 changed files with 530 additions and 26 deletions.
8 changes: 8 additions & 0 deletions apidoc/Titanium/App/iOS/UserNotificationCategory.yml
Expand Up @@ -42,6 +42,14 @@ properties:
osver: {ios: {max: 9.3}}
availability: creation

- name: categorySummaryFormat
summary: A format string for the summary description used when the system groups the category's notifications.
type: String
accessors: false
osver: { ios: { min: 12.0 } }
availability: creation
since: "7.4.0"

- name: identifier
summary: Identifier for this category.
description: |
Expand Down
16 changes: 16 additions & 0 deletions apidoc/Titanium/App/iOS/UserNotificationCenter.yml
Expand Up @@ -209,6 +209,22 @@ properties:
constants: [Titanium.App.iOS.USER_NOTIFICATION_SETTING_*]
osver: {ios: {min: "10.0"}}

- name: criticalAlertSetting
summary: |
The authorization status to play sounds for critical alerts.
Available in Titanium SDK 7.4.0 and later.
type: Number
constants: [Titanium.App.iOS.USER_NOTIFICATION_SETTING_*]
osver: { ios: { min: "12.0" } }

- name: providesAppNotificationSettings
summary: |
A Boolean value indicating the system displays a button for in-app notification settings.
Available in Titanium SDK 7.4.0 and later.
type: Number
constants: [Titanium.App.iOS.USER_NOTIFICATION_SETTING_*]
osver: { ios: { min: "12.0" } }

- name: alertStyle
summary: The current alert style used to display notifications.
type: Number
Expand Down
60 changes: 58 additions & 2 deletions apidoc/Titanium/App/iOS/iOS.yml
Expand Up @@ -272,6 +272,33 @@ properties:
osver: {ios: {min: "8.0"}}
since: "3.4.0"

- name: USER_NOTIFICATION_TYPE_CRITICAL_ALERT
summary: |
The ability to play sounds for critical alerts.
Use with the [types](UserNotificationSettings.types) property.
type: Number
permission: read-only
osver: {ios: {min: "12.0"}}
since: "7.4.0"

- name: USER_NOTIFICATION_TYPE_PROVISIONAL
summary: |
The ability to post non-interrupting notifications provisionally to the Notification Center.
Use with the [types](UserNotificationSettings.types) property.
type: Number
permission: read-only
osver: {ios: {min: "12.0"}}
since: "7.4.0"

- name: USER_NOTIFICATION_TYPE_PROVIDES_APP_NOTIFICATION_SETTINGS
summary: |
An option indicating the system should display a button for in-app notification settings.
Use with the [types](UserNotificationSettings.types) property.
type: Number
permission: read-only
osver: {ios: {min: "12.0"}}
since: "7.4.0"

- name: USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND
summary: |
The action will execute in background. Use with the
Expand Down Expand Up @@ -345,6 +372,17 @@ properties:
osver: {ios: {min: "10.0"}}
since: "7.3.0"


- name: USER_NOTIFICATION_AUTHORIZATION_STATUS_PROVISIONAL
summary: The application is provisionally authorized to post non-interruptive user notifications.
description: |
Used to check the `authorizationStatus` attribute received in
<Titanium.App.iOS.NotificationCenter.requestUserNotificationSettings>.
type: Number
permission: read-only
osver: { ios: { min: "12.0" } }
since: "7.4.0"

- name: USER_NOTIFICATION_SETTING_NOT_SUPPORTED
summary: The application does not support this notification type.
description: |
Expand Down Expand Up @@ -796,17 +834,23 @@ events:
type: String

- name: timezone
summary: Timezone of the date when the notification was configured to fire.
summary: Timezone of the date when the notification was configured to fire. Available in Titanium SDK 7.4.0+.
type: String

- name: userInfo
summary: Custom data object.
type: Dictionary

- name: inBackground
summary: Boolean indicating if notification was received while app was in background (since Titanium SDK 6.2.0).
summary: Boolean indicating if notification was received while app was in background. Available in Titanium SDK 6.2.0+.
type: Boolean

- name: threadIdentifier
summary: |
The unique identifier for the thread or conversation related to this notification request.
It will be used to visually group notifications together. Available in Titanium SDK 7.4.0+ and iOS 12+.
type: String

- name: localnotificationaction
summary: Fired when a user selects an action for an interactive local notification.
properties:
Expand Down Expand Up @@ -1394,6 +1438,18 @@ properties:
osver: {ios: {min: "8.0"}}
since: "7.3.0"

- name: summaryArgument
summary: The string the notification adds to the category's summary format string.
type: String
osver: { ios: { min: "12.0" } }
since: "7.4.0"

- name: summaryArgumentCount
summary: The number of items the notification adds to the category's summary format string.
type: String
osver: { ios: { min: "12.0" } }
since: "7.4.0"

---
name: UserNotificationAttachment
summary: |
Expand Down
8 changes: 8 additions & 0 deletions iphone/Classes/TiApp.m
Expand Up @@ -592,12 +592,20 @@ - (void)application:(UIApplication *)application didRegisterUserNotificationSett
userInfo:@{ @"userNotificationSettings" : notificationSettings }];
}

// iOS 12+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(UNNotification *)notification
{
// Unused so far, may expose as an event in the future?
}

// iOS 10+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
// TODO: Get desired options from notification?
completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound);
}

// iOS 10+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler
{
Expand Down

0 comments on commit c352cb8

Please sign in to comment.