Skip to content

Commit 5ec16bb

Browse files
committed
parsing relevance-score and interruption-level in OSNotification
1 parent 1663cba commit 5ec16bb

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

iOS_SDK/OneSignalSDK/Source/OSNotification.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,20 @@ - (void)parseOtherApnsFields {
189189
if (aps[@"thread-id"]) {
190190
_threadId = (NSString *)aps[@"thread-id"];
191191
}
192+
193+
if (aps[@"relevance-score"]) {
194+
_relevanceScore = (NSNumber *)aps[@"relevance-score"];
195+
}
196+
197+
if (aps[@"interruption-level"]) {
198+
_interruptionLevel = (NSString *)aps[@"interruption-level"];
199+
}
192200

193201
_category = aps[@"category"];
194202
}
195203

196204
- (NSString *)description {
197-
return [NSString stringWithFormat: @"notificationId=%@ templateId=%@ templateName=%@ contentAvailable=%@ mutableContent=%@ category=%@ rawPayload=%@", _notificationId, _templateId, _templateName, _contentAvailable ? @"YES" : @"NO", _mutableContent ? @"YES" : @"NO", _category, _rawPayload];
205+
return [NSString stringWithFormat: @"notificationId=%@ templateId=%@ templateName=%@ contentAvailable=%@ mutableContent=%@ category=%@ relevanceScore=%@ interruptionLevel=%@ rawPayload=%@", _notificationId, _templateId, _templateName, _contentAvailable ? @"YES" : @"NO", _mutableContent ? @"YES" : @"NO", _category, _relevanceScore, _interruptionLevel, _rawPayload];
198206
}
199207

200208
- (NSDictionary *)jsonRepresentation {
@@ -253,6 +261,12 @@ - (NSDictionary *)jsonRepresentation {
253261

254262
if (self.category)
255263
[obj setObject:self.category forKeyedSubscript: @"category"];
264+
265+
if (self.relevanceScore)
266+
[obj setObject:self.relevanceScore forKeyedSubscript: @"relevanceScore"];
267+
268+
if (self.interruptionLevel)
269+
[obj setObject:self.interruptionLevel forKeyedSubscript: @"interruptionLevel"];
256270

257271
return obj;
258272
}

iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3119,6 +3119,8 @@ - (void)testNotificationJson {
31193119
@"content-available": @1,
31203120
@"mutable-content": @1,
31213121
@"alert": @"Message Body",
3122+
@"relevance-score": @0.15,
3123+
@"interruption-level": @"time-sensitive",
31223124
},
31233125
@"os_data": @{
31243126
@"i": @"notif id",

0 commit comments

Comments
 (0)