From b4a5e1115887a66f31fe93fbf6abf9667406eda4 Mon Sep 17 00:00:00 2001 From: mikemilla Date: Tue, 26 Sep 2023 17:18:44 -0700 Subject: [PATCH] Removed wrappers --- CourierReactNativeDelegate.h | 20 ------ CourierReactNativeDelegate.m | 127 ---------------------------------- CourierReactNativeWrapper.m | 24 ------- CourierWrapper.m | 22 ------ src/hooks/CourierProvider.tsx | 2 +- 5 files changed, 1 insertion(+), 194 deletions(-) delete mode 100644 CourierReactNativeDelegate.h delete mode 100644 CourierReactNativeDelegate.m delete mode 100644 CourierReactNativeWrapper.m delete mode 100644 CourierWrapper.m diff --git a/CourierReactNativeDelegate.h b/CourierReactNativeDelegate.h deleted file mode 100644 index 1178085..0000000 --- a/CourierReactNativeDelegate.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// CourierReactNativeDelegate.h -// courier-react-native -// -// Created by Michael Miller on 10/7/22. -// - -#import -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface CourierReactNativeDelegate : UIResponder - -@property (nonatomic, strong) UIWindow *window; - -@end - -NS_ASSUME_NONNULL_END diff --git a/CourierReactNativeDelegate.m b/CourierReactNativeDelegate.m deleted file mode 100644 index ad21726..0000000 --- a/CourierReactNativeDelegate.m +++ /dev/null @@ -1,127 +0,0 @@ -// -// CourierReactNativeDelegate.m -// courier-react-native -// -// Created by Michael Miller on 10/7/22. -// - -@import Courier_iOS; -#import "CourierReactNativeDelegate.h" -#pragma GCC diagnostic ignored "-Wprotocol" -#pragma clang diagnostic ignored "-Wprotocol" - -@implementation CourierReactNativeDelegate - -NSString *iosForegroundNotificationPresentationOptions = @"iosForegroundNotificationPresentationOptions"; -NSUInteger notificationPresentationOptions = UNNotificationPresentationOptionNone; - -- (id) init { - - self = [super init]; - - if (self) { - - // Register for remote notifications - UIApplication *app = [UIApplication sharedApplication]; - [app registerForRemoteNotifications]; - - // Register notification center changes - UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; - center.delegate = self; - - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(notificationPresentationOptionsUpdate:) - name:iosForegroundNotificationPresentationOptions - object:nil - ]; - - [[Courier shared] isUserSignedIn]; - - } - - return(self); - -} - -- (void) notificationPresentationOptionsUpdate:(NSNotification *) notification -{ - if ([[notification name] isEqualToString:iosForegroundNotificationPresentationOptions]) - { - NSDictionary *userInfo = notification.userInfo; - notificationPresentationOptions = ((NSNumber *) [userInfo objectForKey:@"options"]).unsignedIntegerValue; - } -} - -- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler -{ - - UNNotificationContent *content = notification.request.content; - NSDictionary *message = content.userInfo; - - [[Courier shared] trackNotificationWithMessage:message event:CourierPushEventDelivered completionHandler:^(NSError *error) - { - if (error != nil) { - [self log:error]; - } - } - ]; - - NSDictionary *pushNotification = [Courier formatPushNotificationWithContent:content]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationDelivered" object:nil userInfo:pushNotification]; - - completionHandler(notificationPresentationOptions); - -} - -- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler -{ - - UNNotificationContent *content = response.notification.request.content; - NSDictionary *message = content.userInfo; - - [[Courier shared] trackNotificationWithMessage:message event:CourierPushEventClicked completionHandler:^(NSError *error) - { - if (error != nil) { - [self log:error]; - } - } - ]; - - NSDictionary *pushNotification = [Courier formatPushNotificationWithContent:content]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationClicked" object:nil userInfo:pushNotification]; - - dispatch_async(dispatch_get_main_queue(), ^{ - completionHandler(); - }); - -} - -- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error -{ - [self log:error]; -} - -- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken -{ - - [[Courier shared] - setAPNSToken:deviceToken - onSuccess:^() - { - // Empty - } - onFailure:^(NSError *error) - { - [self log:error]; - } - ]; - -} - -- (void)log: (NSError*)error { - NSString *err = [NSString stringWithFormat:@"%@", error]; - [Courier log:err]; -} - -@end diff --git a/CourierReactNativeWrapper.m b/CourierReactNativeWrapper.m deleted file mode 100644 index 0aa8543..0000000 --- a/CourierReactNativeWrapper.m +++ /dev/null @@ -1,24 +0,0 @@ -// -// CourierReactNativeWrapper.m -// courier-react-native -// -// Created by Michael Miller on 8/29/23. -// - -#import - -//@import Courier_iOS; - -@interface CourierReactNativeWrapper : NSObject - -- (void)sayHello; - -@end - -@implementation CourierReactNativeWrapper - -- (void)sayHello { - NSLog(@"Hello from Objective-C!"); -} - -@end diff --git a/CourierWrapper.m b/CourierWrapper.m deleted file mode 100644 index d31ad09..0000000 --- a/CourierWrapper.m +++ /dev/null @@ -1,22 +0,0 @@ -// -// CourierWrapper.m -// courier-react-native -// -// Created by Michael Miller on 8/29/23. -// - -#import - -@interface CourierWrapper : NSObject - -- (void)sayHello; - -@end - -@implementation CourierWrapper - -- (void)sayHello { - NSLog(@"Hello from Objective-C!"); -} - -@end diff --git a/src/hooks/CourierProvider.tsx b/src/hooks/CourierProvider.tsx index c018707..e72116c 100644 --- a/src/hooks/CourierProvider.tsx +++ b/src/hooks/CourierProvider.tsx @@ -1,5 +1,5 @@ import React, { createContext, ReactNode, useContext, useEffect, useState } from 'react'; -import { InboxMessage } from 'src/models/InboxMessage'; +import { InboxMessage } from '../models/InboxMessage'; import Courier, { CourierPushListener, CourierInboxListener, CourierAuthenticationListener, iOSForegroundPresentationOptions } from '..'; let authListener: CourierAuthenticationListener | undefined = undefined