|
| 1 | +/** |
| 2 | +* Copyright (c) 2015-present, Facebook, Inc. |
| 3 | +* All rights reserved. |
| 4 | +* |
| 5 | +* This source code is licensed under the BSD-style license found in the |
| 6 | +* LICENSE file in the root directory of this source tree. An additional grant |
| 7 | +* of patent rights can be found in the PATENTS file in the same directory. |
| 8 | +*/ |
| 9 | + |
| 10 | +#ifndef RCTAzureNotificationHub_h |
| 11 | +#define RCTAzureNotificationHub_h |
| 12 | + |
| 13 | +// Notification Hub events |
| 14 | +extern NSString *const RCTLocalNotificationReceived; |
| 15 | +extern NSString *const RCTRemoteNotificationReceived; |
| 16 | +extern NSString *const RCTRemoteNotificationRegistered; |
| 17 | +extern NSString *const RCTRemoteNotificationRegisteredError; |
| 18 | +extern NSString *const RCTAzureNotificationHubRegistered; |
| 19 | +extern NSString *const RCTAzureNotificationHubRegisteredError; |
| 20 | +extern NSString *const RCTUserNotificationSettingsRegistered; |
| 21 | + |
| 22 | +// Config keys used when registering |
| 23 | +extern NSString *const RCTConnectionStringKey; |
| 24 | +extern NSString *const RCTHubNameKey; |
| 25 | +extern NSString *const RCTTagsKey; |
| 26 | + |
| 27 | +// User info |
| 28 | +extern NSString *const RCTUserInfoNotificationSettings; |
| 29 | +extern NSString *const RCTUserInfoDeviceToken; |
| 30 | +extern NSString *const RCTUserInfoRemote; |
| 31 | +extern NSString *const RCTUserInfoSuccess; |
| 32 | +extern NSString *const RCTUserInfoError; |
| 33 | + |
| 34 | +// Notification types |
| 35 | +extern NSString *const RCTNotificationTypeBadge; |
| 36 | +extern NSString *const RCTNotificationTypeSound; |
| 37 | +extern NSString *const RCTNotificationTypeAlert; |
| 38 | + |
| 39 | +// Errors |
| 40 | +extern NSString *const RCTErrorUnableToRequestPermissions; |
| 41 | +extern NSString *const RCTErrorUnableToRequestPermissionsDetails; |
| 42 | +extern NSString *const RCTErrorUnableToRequestPermissionsTwice; |
| 43 | +extern NSString *const RCTErrorInvalidArguments; |
| 44 | +extern NSString *const RCTErrorMissingConnectionString; |
| 45 | +extern NSString *const RCTErrorMissingHubName; |
| 46 | + |
| 47 | +// Format local notification |
| 48 | +static NSDictionary *RCTFormatLocalNotification(UILocalNotification *notification) |
| 49 | +{ |
| 50 | + NSMutableDictionary *formattedLocalNotification = [NSMutableDictionary dictionary]; |
| 51 | + if (notification.fireDate) |
| 52 | + { |
| 53 | + NSDateFormatter *formatter = [NSDateFormatter new]; |
| 54 | + [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"]; |
| 55 | + NSString *fireDateString = [formatter stringFromDate:notification.fireDate]; |
| 56 | + formattedLocalNotification[@"fireDate"] = fireDateString; |
| 57 | + } |
| 58 | + |
| 59 | + formattedLocalNotification[@"alertAction"] = RCTNullIfNil(notification.alertAction); |
| 60 | + formattedLocalNotification[@"alertBody"] = RCTNullIfNil(notification.alertBody); |
| 61 | + formattedLocalNotification[@"applicationIconBadgeNumber"] = @(notification.applicationIconBadgeNumber); |
| 62 | + formattedLocalNotification[@"category"] = RCTNullIfNil(notification.category); |
| 63 | + formattedLocalNotification[@"soundName"] = RCTNullIfNil(notification.soundName); |
| 64 | + formattedLocalNotification[@"userInfo"] = RCTNullIfNil(RCTJSONClean(notification.userInfo)); |
| 65 | + formattedLocalNotification[@"remote"] = @NO; |
| 66 | + return formattedLocalNotification; |
| 67 | +} |
| 68 | + |
| 69 | +#endif /* RCTAzureNotificationHub_h */ |
0 commit comments