Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Modify OSRequestGetInAppMessages method to include new header values
Motivation: we need to pass the offset, session duration, & retry count to the GET IAM request.
  • Loading branch information
Rodrigo Gomez Palacio committed Oct 23, 2024
commit e7d65f695c0c9f09d977227fbabb27dd6f17d384
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#import "OSInAppMessageClickResult.h"

@interface OSRequestGetInAppMessages : OneSignalRequest
+ (instancetype _Nonnull)withSubscriptionId:(NSString * _Nonnull)subscriptionId;
+ (instancetype _Nonnull)withSubscriptionId:(NSString * _Nonnull)subscriptionId withSessionDuration:(NSNumber * _Nonnull)sessionDuration withRetryCount:(NSNumber *)retryCount withRywToken:(NSString *)rywToken;
@end

@interface OSRequestInAppMessageViewed : OneSignalRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,25 @@ of this software and associated documentation files (the "Software"), to deal
#import "OSInAppMessagingRequests.h"

@implementation OSRequestGetInAppMessages
+ (instancetype _Nonnull)withSubscriptionId:(NSString * _Nonnull)subscriptionId {
+ (instancetype _Nonnull) withSubscriptionId:(NSString * _Nonnull)subscriptionId
withSessionDuration:(NSNumber * _Nonnull)sessionDuration
withRetryCount:(NSNumber *)retryCount
withRywToken:(NSString *)rywToken
{
let request = [OSRequestGetInAppMessages new];
request.method = GET;
let headers = [NSMutableDictionary new];

if (sessionDuration != nil) {
// convert to ms & round
sessionDuration = @(round([sessionDuration doubleValue] * 1000));
headers[@"OneSignal-Session-Duration" ] = [sessionDuration stringValue];
}
headers[@"OneSignal-RYW-Token"] = rywToken;
headers[@"OneSignal-Retry-Count"] = [retryCount stringValue];

request.additionalHeaders = headers;

NSString *appId = [OneSignalConfigManager getAppId];
request.path = [NSString stringWithFormat:@"apps/%@/subscriptions/%@/iams", appId, subscriptionId];
return request;
Expand Down