Skip to content
Open
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
2 changes: 0 additions & 2 deletions ios/RCTOneSignal/RCTOneSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

+ (RCTOneSignal *) sharedInstance;

@property (nonatomic) BOOL didStartObserving;

- (void)initOneSignal:(NSDictionary *)launchOptions;

@end
36 changes: 0 additions & 36 deletions ios/RCTOneSignal/RCTOneSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,13 @@
#import "RCTOneSignal.h"
#import "RCTOneSignalEventEmitter.h"

#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0

#define UIUserNotificationTypeAlert UIRemoteNotificationTypeAlert
#define UIUserNotificationTypeBadge UIRemoteNotificationTypeBadge
#define UIUserNotificationTypeSound UIRemoteNotificationTypeSound
#define UIUserNotificationTypeNone UIRemoteNotificationTypeNone
#define UIUserNotificationType UIRemoteNotificationType

#endif

@interface RCTOneSignal ()
@end

@implementation RCTOneSignal {
BOOL didInitialize;
}

OSNotificationOpenedResult* coldStartOSNotificationOpenedResult;

+ (RCTOneSignal *) sharedInstance {
static dispatch_once_t token = 0;
static id _sharedInstance = nil;
Expand All @@ -50,26 +38,6 @@ - (void)initOneSignal:(NSDictionary *)launchOptions {
didInitialize = true;
}

- (void)handleRemoteNotificationOpened:(NSString *)result {
NSDictionary *json = [self jsonObjectWithString:result];

if (json)
[self sendEvent:OSEventString(NotificationOpened) withBody:json];
}

- (NSDictionary *)jsonObjectWithString:(NSString *)jsonString {
NSError *jsonError;
NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonError];

if (jsonError) {
[OneSignal onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"Unable to serialize JSON string into an object: %@", jsonError]];
return nil;
}

return json;
}

- (void)sendEvent:(NSString *)eventName withBody:(NSDictionary *)body {
[RCTOneSignalEventEmitter sendEventWithName:eventName withBody:body];
}
Expand All @@ -86,8 +54,4 @@ - (void)onOSPermissionChanged:(OSPermissionStateChanges *)stateChanges {
[self sendEvent:OSEventString(PermissionChanged) withBody:stateChanges.toDictionary];
}

- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end