Skip to content

Commit be64a25

Browse files
committed
Refactored strings for iOS.
1 parent 1f6a6de commit be64a25

File tree

5 files changed

+176
-119
lines changed

5 files changed

+176
-119
lines changed

ios/AzureNotificationHubIOS.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ const PushNotificationEmitter = new NativeEventEmitter(RCTAzureNotificationHubMa
2121

2222
const _notifHandlers = new Map();
2323

24-
const DEVICE_NOTIF_EVENT = 'remoteNotificationReceived';
25-
const NOTIF_REGISTER_EVENT = 'remoteNotificationsRegistered';
26-
const NOTIF_REGISTRATION_ERROR_EVENT = 'remoteNotificationRegistrationError';
27-
const NOTIF_REGISTER_AZURE_HUB_EVENT = 'azureNotificationHubRegistered';
28-
const NOTIF_AZURE_HUB_REGISTRATION_ERROR_EVENT = 'azureNotificationHubRegistrationError';
29-
const DEVICE_LOCAL_NOTIF_EVENT = 'localNotificationReceived';
24+
const DEVICE_LOCAL_NOTIF_EVENT = 'localNotificationReceived';
25+
const DEVICE_NOTIF_EVENT = 'remoteNotificationReceived';
26+
const NOTIF_REGISTER_EVENT = 'remoteNotificationRegistered';
27+
const NOTIF_REGISTRATION_ERROR_EVENT = 'remoteNotificationRegisteredError';
28+
const NOTIF_REGISTER_AZURE_HUB_EVENT = 'azureNotificationHubRegistered';
29+
const NOTIF_AZURE_HUB_REGISTRATION_ERROR_EVENT = 'azureNotificationHubRegisteredError';
3030

3131
/**
3232
* An event emitted by AzureNotificationHubIOS.

ios/RCTAzureNotificationHubManager.xcodeproj/project.pbxproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
16D92203240700B100FB17C6 /* RCTAzureNotificationHub.m in Sources */ = {isa = PBXBuildFile; fileRef = 16D92202240700B100FB17C6 /* RCTAzureNotificationHub.m */; };
1011
458BD41D1D9EDE5E007E3F13 /* RCTAzureNotificationHubManager.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 458BD41C1D9EDE5E007E3F13 /* RCTAzureNotificationHubManager.h */; };
1112
458BD41F1D9EDE5E007E3F13 /* RCTAzureNotificationHubManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 458BD41E1D9EDE5E007E3F13 /* RCTAzureNotificationHubManager.m */; };
1213
/* End PBXBuildFile section */
@@ -25,6 +26,8 @@
2526
/* End PBXCopyFilesBuildPhase section */
2627

2728
/* Begin PBXFileReference section */
29+
16D92201240700B100FB17C6 /* RCTAzureNotificationHub.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAzureNotificationHub.h; sourceTree = "<group>"; };
30+
16D92202240700B100FB17C6 /* RCTAzureNotificationHub.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAzureNotificationHub.m; sourceTree = "<group>"; };
2831
458BD4191D9EDE5E007E3F13 /* libRCTAzureNotificationHubManager.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTAzureNotificationHubManager.a; sourceTree = BUILT_PRODUCTS_DIR; };
2932
458BD41C1D9EDE5E007E3F13 /* RCTAzureNotificationHubManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTAzureNotificationHubManager.h; sourceTree = "<group>"; };
3033
458BD41E1D9EDE5E007E3F13 /* RCTAzureNotificationHubManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTAzureNotificationHubManager.m; sourceTree = "<group>"; };
@@ -60,6 +63,8 @@
6063
458BD41B1D9EDE5E007E3F13 /* RCTAzureNotificationHubManager */ = {
6164
isa = PBXGroup;
6265
children = (
66+
16D92201240700B100FB17C6 /* RCTAzureNotificationHub.h */,
67+
16D92202240700B100FB17C6 /* RCTAzureNotificationHub.m */,
6368
458BD41C1D9EDE5E007E3F13 /* RCTAzureNotificationHubManager.h */,
6469
458BD41E1D9EDE5E007E3F13 /* RCTAzureNotificationHubManager.m */,
6570
);
@@ -105,6 +110,7 @@
105110
developmentRegion = English;
106111
hasScannedForEncodings = 0;
107112
knownRegions = (
113+
English,
108114
en,
109115
);
110116
mainGroup = 458BD4101D9EDE5E007E3F13;
@@ -122,6 +128,7 @@
122128
isa = PBXSourcesBuildPhase;
123129
buildActionMask = 2147483647;
124130
files = (
131+
16D92203240700B100FB17C6 /* RCTAzureNotificationHub.m in Sources */,
125132
458BD41F1D9EDE5E007E3F13 /* RCTAzureNotificationHubManager.m in Sources */,
126133
);
127134
runOnlyForDeploymentPostprocessing = 0;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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 */
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
// Notification Hub events
11+
NSString *const RCTLocalNotificationReceived = @"localNotificationReceived";
12+
NSString *const RCTRemoteNotificationReceived = @"remoteNotificationReceived";
13+
NSString *const RCTRemoteNotificationRegistered = @"remoteNotificationRegistered";
14+
NSString *const RCTRemoteNotificationRegisteredError = @"remoteNotificationRegisteredError";
15+
NSString *const RCTAzureNotificationHubRegistered = @"azureNotificationHubRegistered";
16+
NSString *const RCTAzureNotificationHubRegisteredError = @"azureNotificationHubRegisteredError";
17+
NSString *const RCTUserNotificationSettingsRegistered = @"userNotificationSettingsRegistered";
18+
19+
// Config keys used when registering
20+
NSString *const RCTConnectionStringKey = @"connectionString";
21+
NSString *const RCTHubNameKey = @"hubName";
22+
NSString *const RCTTagsKey = @"tags";
23+
24+
// User info
25+
NSString *const RCTUserInfoNotificationSettings = @"notificationSettings";
26+
NSString *const RCTUserInfoDeviceToken = @"deviceToken";
27+
NSString *const RCTUserInfoRemote = @"remote";
28+
NSString *const RCTUserInfoSuccess = @"success";
29+
NSString *const RCTUserInfoError = @"error";
30+
31+
// Notification types
32+
NSString *const RCTNotificationTypeBadge = @"badge";
33+
NSString *const RCTNotificationTypeSound = @"sound";
34+
NSString *const RCTNotificationTypeAlert = @"alert";
35+
36+
// Errors
37+
NSString *const RCTErrorUnableToRequestPermissions = @"Unabled to request permissions";
38+
NSString *const RCTErrorUnableToRequestPermissionsDetails = @"Requesting push notifications is currently unavailable in an app extension";
39+
NSString *const RCTErrorUnableToRequestPermissionsTwice = @"Cannot call requestPermissions twice before the first has returned.";
40+
NSString *const RCTErrorInvalidArguments = @"Invalid arguments";
41+
NSString *const RCTErrorMissingConnectionString = @"Connection string cannot be null.";
42+
NSString *const RCTErrorMissingHubName = @"Hub name cannot be null.";

0 commit comments

Comments
 (0)