You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 6, 2023. It is now read-only.
Hey @artemyarulin , I am trying to use this library with UserNotification service extension.
#import "NotificationService.h"
#import "React/RCTBridge.h"
#import <React/RCTLog.h>
#import "RNMEvaluator.h"
@interface NotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@end
@implementation NotificationService{
__weak RCTBridge *_bridge;
}
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
RCTBridge* bridge = [[RCTBridge alloc] initWithBundleURL:[NSURL URLWithString:@"index"]
moduleProvider:nil
launchOptions:nil];
[RNMEvaluator callSyncFunction:bridge
name:@"Math.pow"
args:@[@2,@2]
cb:^(NSString *error, id returnValue) {
if (error)
NSLog(@"Error occured: %@", error);
else
NSLog(@"Function returned: %@", returnValue);
}];
// I want the callback to be executed first before executing further code.
self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [Modified]",
self.bestAttemptContent.title];
self.contentHandler(self.bestAttemptContent);
}
- (void)serviceExtensionTimeWillExpire {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
self.contentHandler(self.bestAttemptContent);
}
@end
Although can I somehow wait for cb (or callback) before proceeding in code? I mean NSLog(@"Error occured: %@", error); should be executed before I try to assign value to self.bestAttemptContent.title
Hey @artemyarulin , I am trying to use this library with UserNotification service extension.
Although can I somehow wait for
cb(or callback) before proceeding in code? I meanNSLog(@"Error occured: %@", error);should be executed before I try to assign value toself.bestAttemptContent.titleP.S. I am objective-c nube!!