Skip to content

Commit 4bda360

Browse files
authored
Merge pull request #19 from phongcao/user-tags
User tags and RN 0.40+.
2 parents 7117d0a + 6b4d2d1 commit 4bda360

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

ios/AzureNotificationHubIOS.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {NativeEventEmitter} from 'react-native';
1515
import {NativeModules} from 'react-native';
1616

1717
const RCTAzureNotificationHubManager = NativeModules.AzureNotificationHubManager;
18-
const invariant = require('../../react-native/node_modules/fbjs/lib/invariant');
18+
const invariant = require('fbjs/lib/invariant');
1919

2020
const PushNotificationEmitter = new NativeEventEmitter(RCTAzureNotificationHubManager);
2121

ios/RCTAzureNotificationHubManager/RCTAzureNotificationHubManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
99

10-
#import "RCTEventEmitter.h"
10+
#import "React/RCTEventEmitter.h"
1111

1212
@interface RCTAzureNotificationHubManager : RCTEventEmitter
1313

ios/RCTAzureNotificationHubManager/RCTAzureNotificationHubManager.m

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
#import <WindowsAzureMessaging/WindowsAzureMessaging.h>
1111
#import "RCTAzureNotificationHubManager.h"
1212

13-
#import "RCTBridge.h"
14-
#import "RCTConvert.h"
15-
#import "RCTEventDispatcher.h"
16-
#import "RCTUtils.h"
13+
#import "React/RCTBridge.h"
14+
#import "React/RCTConvert.h"
15+
#import "React/RCTEventDispatcher.h"
16+
#import "React/RCTUtils.h"
1717

1818
// The default error code to use as the `code` property for callback error objects
1919
RCT_EXTERN NSString *const RCTErrorUnspecified;
@@ -35,6 +35,7 @@
3535
// Keys
3636
NSString *const RCTConnectionStringKey = @"connectionString";
3737
NSString *const RCTHubNameKey = @"hubName";
38+
NSString *const RCTTagsKey = @"tags";
3839

3940
@implementation RCTConvert (UILocalNotification)
4041

@@ -69,6 +70,9 @@ @implementation RCTAzureNotificationHubManager
6970

7071
// The Notification Hub name
7172
NSString *_hubName;
73+
74+
// The Notification Hub tags
75+
NSSet *_tags;
7276
}
7377

7478
static NSDictionary *RCTFormatLocalNotification(UILocalNotification *notification)
@@ -441,25 +445,26 @@ - (void)handleRegisterUserNotificationSettings:(NSNotification *)notification
441445
resolver:(RCTPromiseResolveBlock)resolve
442446
rejecter:(RCTPromiseRejectBlock)reject)
443447
{
444-
// Store the connection string and hub name
448+
// Store the connection string, hub name and tags
445449
_connectionString = [config objectForKey:RCTConnectionStringKey];
446450
_hubName = [config objectForKey:RCTHubNameKey];
447-
451+
_tags = [config objectForKey:RCTTagsKey];
452+
448453
// Check arguments
449454
if (![self assertArguments:reject])
450455
{
451456
return;
452457
}
453458

454459
// Initialize hub
455-
SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:_connectionString
460+
SBNotificationHub *hub = [[SBNotificationHub alloc] initWithConnectionString:_connectionString
456461
notificationHubPath:_hubName];
457462

458463
// Register for native notifications
459464
dispatch_async(dispatch_get_main_queue(), ^
460465
{
461466
[hub registerNativeWithDeviceToken:deviceToken
462-
tags:nil
467+
tags:_tags
463468
completion:^(NSError* error)
464469
{
465470
if (error != nil)
@@ -488,13 +493,13 @@ - (void)handleRegisterUserNotificationSettings:(NSNotification *)notification
488493
}
489494

490495
// Initialize hub
491-
SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:_connectionString
496+
SBNotificationHub *hub = [[SBNotificationHub alloc] initWithConnectionString:_connectionString
492497
notificationHubPath:_hubName];
493498

494499
// Unregister for native notifications
495500
dispatch_async(dispatch_get_main_queue(), ^
496501
{
497-
[hub unregisterNativeWithCompletion:^(NSError* error)
502+
[hub unregisterNativeWithCompletion:^(NSError *error)
498503
{
499504
if (error != nil)
500505
{

0 commit comments

Comments
 (0)