1
주 스레드에서 html 페이지를 렌더링 중입니다. 따라서 메시지를 계속 삭제할 때 Pusher를 주 스레드와 동일한 스레드에서 실행할 수 없습니다.백그라운드에서 푸셔 실행 스레드 iOS
iOS의 백그라운드 스레드에서 항상 푸셔를 실행하는 방법이 있습니까?
그랜드 센트럴 디스패치를 시도했지만 초기화 후 작동하지 않습니다. 푸셔가 메인 스레드로 돌아옵니다.
고맙습니다.
이것은 내가 지금까지 가지고있는 것입니다.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
client = [PTPusher pusherWithKey:@"xxxxxxxx" delegate:self encrypted:NO];
client.reconnectAutomatically = YES;
client.reconnectDelay = 1; // defaults to 5 seconds
[client connect];
PTPusherChannel *channel = [client subscribeToChannelNamed:[NSString stringWithFormat:@"Company_%@", [Settings sharedSettings].company.companyID]];
[channel bindToEventNamed:@"ServicePrint" handleWithBlock:^(PTPusherEvent *channelEvent) {
NSLog(@"[pusher event] Received event %@", channelEvent);
//do some work here
}];
dispatch_async(dispatch_get_main_queue(), ^{
// Add code here to update the UI/send notifications based on the
// results of the background processing
});
});
'떨어지는'메시지는 무엇입니까? –
새 알림이 수신됩니다. 메인 스레드가 사용되는 동안 일부 알림이 삭제됩니다. – Jagdeep
이 작업을 위해 특별히 만들어진 NSOperation을 사용하려고합니까? NSOperationQueue? –