Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup - iOS misc RCTOneSignal (Needs testing) #1196

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions ios/RCTOneSignal/RCTOneSignal.h
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
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