I'm facing an issue about Push Notification with Notification Service Extension (NSE). Steps:
Allow Push Permissions and a valid device_token has been returned. The Push Notification come successfully and has handled by NSE. The NSE take some seconds for complete.
When a Push is coming and the NSE is processing (not call contentHandler yet). Quickly delete the app.
Then, we reinstall the app. Now, we can see:
A content of push was called to didReceiveRemoteNotification of AppDelegate of main app (Not NSE).
A valid device token has been returned to didRegisterForRemoteNotificationsWithDeviceToken without calling registerForRemoteNotifications and any Permissions. We can use this device_token to push.
I can see it on: iOS 16.3 (Beta), iOS 16.1.1 (Final)...
I can check the Permissions of the Push Notification before use the device_token. But It doesn't make sense. Do we have some best solutions for this?
Thanks.
Post
Replies
Boosts
Views
Activity
I'm developing iOS framework with Objective C.
I create a dispatch_queue_t by using dispatch_queue_create. And call CFRunLoopRun() for run the Runloop in the queue.
But, It looks like the dispatch_queue_t has share the RunLoop. Some classes has add an invalid timer, and when I call the CFRunLoopRun(), It crashed on my side.
Sample code:
- (void)viewDidLoad {
[super viewDidLoad];
self.queue1 = dispatch_queue_create("com.queue1", DISPATCH_QUEUE_CONCURRENT);
self.queue2 = dispatch_queue_create("org.queue2", DISPATCH_QUEUE_CONCURRENT);
}
- (IBAction)btnButtonAction:(id)sender {
dispatch_async(self.queue1, ^{
NSString *runloop = [NSString stringWithFormat:@"%@", CFRunLoopGetCurrent()];
runloop = [runloop substringWithRange:NSMakeRange(0, 22)];
NSLog(@"Queue1 %p run: %@", self.queue1, runloop);
//NSTimer *timer = [[NSTimer alloc] initWithFireDate:[NSDate date] interval:1 target:self selector:@selector(wrongSeletor:) userInfo:nil repeats:NO];
//[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
});
dispatch_async(self.queue2, ^{
NSString *runloop = [NSString stringWithFormat:@"%@", CFRunLoopGetCurrent()];
runloop = [runloop substringWithRange:NSMakeRange(0, 22)];
NSLog(@"Queue2 %p run: %@", self.queue2, runloop);
CFRunLoopRun();
});
}
Some time they take same RunLoop:
https://i.stack.imgur.com/wGcv3.png
=====
You can see the crash by uncomment the code of NSTimer. The NSTimer has been added in queue1, but it still running when call CFRunLoopRun() in queue2.
I have read some description like: https://stackoverflow.com/questions/38000727/need-some-clarifications-about-dispatch-queue-thread-and-nsrunloop
They told that: "system creates a run loop for the thread". But, in my check, they are sharing the RunLoop.
This is sad for me, because I facing that crashes happen when calling CFRunLoopRun() on production.
Can someone take a look at this.