Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 5 additions & 9 deletions iOS_SDK/OneSignalSDK/Source/OneSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -1658,16 +1658,10 @@ + (void)notificationReceived:(NSDictionary*)messageDict isActive:(BOOL)isActive

if (opened) {
//app was in background / not running and opened due to a tap on a notification or an action check what type
NSString* actionSelected = NULL;
OSNotificationActionType type = OSNotificationActionTypeOpened;
if (messageDict[@"custom"][@"a"][@"actionSelected"]) {
actionSelected = messageDict[@"custom"][@"a"][@"actionSelected"];
type = OSNotificationActionTypeActionTaken;
}
if (messageDict[@"actionSelected"]) {
actionSelected = messageDict[@"actionSelected"];

if (messageDict[@"custom"][@"a"][@"actionSelected"] || messageDict[@"actionSelected"])
type = OSNotificationActionTypeActionTaken;
}

// Call Action Block
[OneSignal handleNotificationOpened:messageDict isActive:isActive actionType:type displayType:OneSignal.inFocusDisplayType];
Expand Down Expand Up @@ -2017,7 +2011,8 @@ + (void)setEmail:(NSString * _Nonnull)email withEmailAuthHashToken:(NSString * _

//checks to make sure that if email_auth is required, the user has passed in a hash token
if (self.currentEmailSubscriptionState.requiresEmailAuth && (!emailAuthToken || emailAuthToken.length == 0)) {
failureBlock([NSError errorWithDomain:@"com.onesignal.email" code:0 userInfo:@{@"error" : @"Email authentication (auth token) is set to REQUIRED for this application. Please provide an auth token from your backend server or change the setting in the OneSignal dashboard."}]);
if (failureBlock)
failureBlock([NSError errorWithDomain:@"com.onesignal.email" code:0 userInfo:@{@"error" : @"Email authentication (auth token) is set to REQUIRED for this application. Please provide an auth token from your backend server or change the setting in the OneSignal dashboard."}]);
return;
}

Expand Down Expand Up @@ -2205,6 +2200,7 @@ + (void)load {
return;
}


// Swizzle - UIApplication delegate
injectToProperClass(@selector(setOneSignalDelegate:), @selector(setDelegate:), @[], [OneSignalAppDelegate class], [UIApplication class]);

Expand Down
13 changes: 6 additions & 7 deletions iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ - (id)initWithFilePath:(NSString*)path {
@end

@interface NSURLSession (DirectDownload)
+ (NSString *)downloadItemAtURL:(NSURL *)url toFile:(NSString *)localPath error:(NSError *)error;
+ (NSString *)downloadItemAtURL:(NSURL *)url toFile:(NSString *)localPath error:(NSError **)error;
@end

@implementation NSURLSession (DirectDownload)

+ (NSString *)downloadItemAtURL:(NSURL *)url toFile:(NSString *)localPath error:(NSError *)error {
+ (NSString *)downloadItemAtURL:(NSURL *)url toFile:(NSString *)localPath error:(NSError **)error {
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];

DirectDownloadDelegate *delegate = [[DirectDownloadDelegate alloc] initWithFilePath:localPath];
Expand All @@ -132,9 +132,8 @@ + (NSString *)downloadItemAtURL:(NSURL *)url toFile:(NSString *)localPath error:

NSError *downloadError = [delegate error];
if (downloadError != nil) {
if (error != nil) {
error = downloadError;
}
if (error)
*error = downloadError;
return nil;
}

Expand Down Expand Up @@ -753,8 +752,8 @@ + (NSString*)downloadMediaAndSaveInBundle:(NSString*)urlString {
//guard against situations where for example, available storage is too low

@try {
NSError* error = nil;
let mimeType = [NSURLSession downloadItemAtURL:url toFile:filePath error:error];
NSError* error;
let mimeType = [NSURLSession downloadItemAtURL:url toFile:filePath error:&error];

if (error) {
[OneSignal onesignal_Log:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"Encountered an error while attempting to download file with URL: %@", error]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ + (void)load {
}

// Override downloading of media attachment
+ (NSString *)overrideDownloadItemAtURL:(NSURL*)url toFile:(NSString*)localPath error:(NSError*)error {
+ (NSString *)overrideDownloadItemAtURL:(NSURL*)url toFile:(NSString*)localPath error:(NSError**)error {
NSString *content = @"File Contents";
NSData *fileContents = [content dataUsingEncoding:NSUTF8StringEncoding];
[[NSFileManager defaultManager] createFileAtPath:localPath
Expand Down