Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
helenaford committed Nov 29, 2021
1 parent 8c0bc0f commit d3e586d
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 19 deletions.
29 changes: 27 additions & 2 deletions ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#import <UIKit/UIKit.h>
#import "NotifeeCore+NSNotificationCenter.h"
#import "NotifeeCore+UNUserNotificationCenter.h"
#import "NotifeeCoreDelegateHolder.h"
#import "NotifeeCoreUtil.h"

@implementation NotifeeCoreNSNotificationCenter

Expand Down Expand Up @@ -65,8 +67,31 @@ - (void)application_onDidFinishLaunchingNotification:(nonnull NSNotification *)n
[[NotifeeCoreUNUserNotificationCenter instance] observe];
}

- (void)messaging_didReceiveRemoteNotification:(nonnull NSNotification *)notification {
// update me with logic
//
- (void)messaging_didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo {
if ([NotifeeCoreUtil isAppExtension]) {
return;
}

UIApplication *application = (UIApplication *)[NotifeeCoreUtil notifeeUIApplication];

if (application.applicationState == UIApplicationStateActive) {
if (userInfo[@"aps"][@"alert"] == nil) {
NSDictionary *notifeeNotification = userInfo[kNotifeeUserInfoNotification];

// handle notification outside of notifee
if (notifeeNotification == nil) {
// TODO: parse user info
}

[[NotifeeCoreDelegateHolder instance] didReceiveNotifeeCoreEvent:@{
@"type" : @(NotifeeCoreEventTypeIncoming),
@"detail" : @{
// @"notification" : @"2",
}
}];
}
}
}

@end
11 changes: 9 additions & 2 deletions ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
NSDictionary *notifeeNotification =
notification.request.content.userInfo[kNotifeeUserInfoNotification];

// handle notification outside of notifee
if (notifeeNotification == nil) {
notifeeNotification = [NotifeeCoreUtil parseUNNotificationRequest:notification.request];
}

// we only care about notifications created through notifee
if (notifeeNotification != nil) {
UNNotificationPresentationOptions presentationOptions = UNNotificationPresentationOptionNone;
Expand Down Expand Up @@ -139,11 +144,13 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
NSDictionary *notifeeNotification = response.notification.request.content.userInfo[kNotifeeUserInfoNotification];
NSDictionary *notifeeNotification =
response.notification.request.content.userInfo[kNotifeeUserInfoNotification];

// handle notification outside of notifee
if (notifeeNotification == nil) {
notifeeNotification = [NotifeeCoreUtil parseUNNotificationRequest:response.notification.request];
notifeeNotification =
[NotifeeCoreUtil parseUNNotificationRequest:response.notification.request];
}

// handle notification
Expand Down
2 changes: 1 addition & 1 deletion ios/NotifeeCore/NotifeeCore.m
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ + (void)displayNotification:(NSDictionary *)notification withBlock:(notifeeMetho

[center addNotificationRequest:request
withCompletionHandler:^(NSError *error) {
UIApplication *application = [NotifeeCoreUtil notifeeUIApplication];
UIApplication *application = (UIApplication *)[NotifeeCoreUtil notifeeUIApplication];
if (error == nil && application.applicationState != UIApplicationStateActive) {
[[NotifeeCoreDelegateHolder instance] didReceiveNotifeeCoreEvent:@{
@"type" : @(NotifeeCoreEventTypeDelivered),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request
// [NotifeeExtensionHelper populateNotificationContent:self.bestAttemptContent
// withContentHandler:contentHandler];

[NotifeeExtensionHelper populateNotificationContent:request
withContent:self.bestAttemptContent
withContentHandler:contentHandler];
// [NotifeeExtensionHelper populateNotificationContent:request
// withContent:self.bestAttemptContent
// withContentHandler:contentHandler];
}

- (void)serviceExtensionTimeWillExpire {
Expand Down
2 changes: 1 addition & 1 deletion tests_react_native/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
# with this set to false this will be the same way the user would consume NotifeeCore framework
# Note: you must pod install after changing this value

$NotifeeCoreFromSources = false
$NotifeeCoreFromSources = true
$NotifeeExtension = true


Expand Down
24 changes: 14 additions & 10 deletions tests_react_native/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ PODS:
- nanopb/encode (= 2.30908.0)
- nanopb/decode (2.30908.0)
- nanopb/encode (2.30908.0)
- NotifeeCore (1.0.0)
- PromisesObjC (2.0.0)
- RCT-Folly (2021.06.28.00-v2):
- boost
Expand Down Expand Up @@ -357,12 +358,11 @@ PODS:
- Firebase/Messaging (= 8.8.0)
- React-Core
- RNFBApp
- RNNotifee (3.0.3):
- RNNotifee (4.0.0-0):
- NotifeeCore
- React-Core
- RNNotifeeCore
- RNNotifeeCore (3.0.3):
- RNNotifeeCore/NotifeeCore (= 3.0.3)
- RNNotifeeCore/NotifeeCore (3.0.3)
- RNNotifeeCore (4.0.0-0):
- NotifeeCore
- Yoga (1.14.0)

DEPENDENCIES:
Expand All @@ -374,6 +374,7 @@ DEPENDENCIES:
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
- hermes-engine (~> 0.9.0)
- libevent (~> 2.1.12)
- NotifeeCore (from `../../ios`)
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
- RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
Expand Down Expand Up @@ -435,6 +436,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/React/FBReactNativeSpec"
glog:
:podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
NotifeeCore:
:path: "../../ios"
RCT-Folly:
:podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec"
RCTRequired:
Expand Down Expand Up @@ -508,14 +511,15 @@ SPEC CHECKSUMS:
FirebaseInstallations: 2563cb18a723ef9c6ef18318a49519b75dce613c
FirebaseMessaging: 419b5c9d84f294a753c6501d8cfb9ced1ce37304
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 85ecdd10ee8d8ec362ef519a6a45ff9aa27b2e85
glog: 5337263514dd6f09803962437687240c5dc39aa4
GoogleDataTransport: 85fd18ff3019bb85d3f2c551d04c481dedf71fc9
GoogleUtilities: 8de2a97a17e15b6b98e38e8770e2d129a57c0040
hermes-engine: bf7577d12ac6ccf53ab8b5af3c6ccf0dd8458c5c
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96
NotifeeCore: 7163fe1ba23401a81430438a037a40a00221b80e
PromisesObjC: 68159ce6952d93e17b2dfe273b8c40907db5ba58
RCT-Folly: 803a9cfd78114b2ec0f140cfa6fa2a6bafb2d685
RCT-Folly: a21c126816d8025b547704b777a2ba552f3d9fa9
RCTRequired: e94bac8c0770aa02dd4959b86e32c6fe0e077e2d
RCTTypeSafety: 400db7e174b0cb36ba4b85aaef60789df434043e
React: 921833f22439a2cf6dbc760a56ee1bfc54aeed03
Expand All @@ -542,10 +546,10 @@ SPEC CHECKSUMS:
ReactCommon: fda8de1535cec34971adef653f9afd954142eb7c
RNFBApp: 729c0666395b1953198dc4a1ec6deb8fbe1c302e
RNFBMessaging: 8415ec196e5c1196caa26ec0742cdb48ed4d0f97
RNNotifee: f0d07c9f1829438ff3b5f80e66b405891bf54479
RNNotifeeCore: 218e4080fb14f8ddfb5d454853baac1bb46cd1d9
RNNotifee: 76848114415d00108f6139dfcdb656903ea09cab
RNNotifeeCore: 0b45d6cce948a491099d8c65f5ea04e452bc4d6f
Yoga: 63f25ad38b6f7597fa5dfee27088b29a01e83447

PODFILE CHECKSUM: 8566c3eec5afcd7bbe46173879c6fc8b9dc375ee
PODFILE CHECKSUM: 5a8c08f65af9bf9f8543478056186aaf3b8e42ef

COCOAPODS: 1.11.2
1 change: 1 addition & 0 deletions tests_react_native/ios/testing/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<array>
<string>fetch</string>
<string>location</string>
<string>processing</string>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
Expand Down

0 comments on commit d3e586d

Please sign in to comment.