Reputation: 336
I have a scheduler that runs every 15 minutes to check if there is any notifications to be sent to registered devices via azure notification hubs. Scheduler gets the tag string(s) and notification message and sends it to this method 'SendAppleNativeNotificationAsync(message, tags)'. There can be multiple messages to be sent for different tag combinations.
Lets say
device A - tagged with 'gender:female', 'age: 25', 'ageGroup:20-30' device B - tagged with 'gender:male', 'age:31', 'ageGroup:30-40' device C - tagged with 'gender:female', 'age: 35', 'ageGroup:30-40'
and I have 3 notifications to be sent in current 15 minutes cycle message 1 for tag 'gender:female' and message 2 for tag 'ageGroup:30-40' message 3 for tag 'gender:male'
Now the problem is device C and B falls under multiple notifications category and it is supposed to receive multiple messages just within few seconds.
I am looking for an option to avoid/ handle this scenario better. I would appreciate any help. Thank you
Upvotes: 1
Views: 549
Reputation: 4965
I got a new idea, you could indeed use tag expressions to achieve your goal:
SendAppleNativeNotificationAsync(Message1, '(gender:female && !ageGroup:30-40 && !gender:male)');
SendAppleNativeNotificationAsync(Message2, '(ageGroup:30-40 && !gender:female && !gender:male)');
SendAppleNativeNotificationAsync(Message3, '(gender:male !ageGroup:30-40 && !gender:female)');
SendAppleNativeNotificationAsync(merge(Message1,Message2), '(gender:female && ageGroup:30-40 && !gender:male)');
SendAppleNativeNotificationAsync(merge(Message2,Message3), '(ageGroup:30-40 && gender:male && !gender:female)');
SendAppleNativeNotificationAsync(merge(Message1,Message3), '(gender:female && gender:male && !ageGroup:30-40)'); //everything is possible!
SendAppleNativeNotificationAsync(merge(Message1,Message2,Message3), '(gender:female && gender:male && ageGroup:30-40)');
Of course you should implement some algorithm for this, but I guess you will get the idea... Downside of this solution is that the expressions are limited to 6 tags, so this will only work, if you have 6 tags at most. You could do this as the first iteration, but to be future-proof, I would suggest to stick with the original answer...
I guess the Azure Notification Hub is not designed to handle such a scenario. I would say your best option is to don't use the tags on the Azure Notification Hub but to implement some mapping on your own.
Upvotes: 1
Reputation: 1604
Tag expressions may help. If you message itself is same then just combine your tags to expression like this "gender:female || ageGroup:30-40 || gender:male". You can have up to 20 tags if only '||' operator is used.
If it does not work then we could discuss more options but I'll need more details about you business-logic.
Upvotes: 1