iOS가 사용자가 강제 종료 한 경우 앱을 백그라운드에서 시작합니까?
content-available
푸시 알림 에서 플래그를 사용하여 백그라운드 가져 오기를 트리거하고 있습니다. 나는이 fetch
와 remote-notification
UIBackgroundModes
있었습니다.
AppDelegate.m에서 사용중인 구현은 다음과 같습니다.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
NSLog(@"Remote Notification Recieved");
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = @"Looks like i got a notification - fetch thingy";
[application presentLocalNotificationNow:notification];
completionHandler(UIBackgroundFetchResultNewData);
}
앱이 백그라운드에서 실행 중이면 정상적으로 작동합니다. (알림이 수신되고 앱은 위의 코드와 같이 "알림이있는 것처럼 보입니다"로컬 알림을 트리거했습니다.)
그러나 응용 프로그램이 실행되지 않을 때 와 푸시 통지가와 수신 content-available
플래그, 응용 프로그램이 시작되지 않고 및 didRecieveRemoteNotification
대리자 메서드는 호출되지 않습니다.
멀티 태스킹의 새로운 기능 WWDC 비디오 (WWDC 2013의 # 204)는 다음과 같이 표시됩니다.
content-available
플래그 와 함께 푸시 알림을 받으면 응용 프로그램이 "백그라운드로 시작됩니다"라고 말합니다 .
내 앱이 백그라운드에서 시작되지 않는 이유는 무엇입니까?
실제 질문은 다음과 같습니다.
사용자가 앱을 강제 종료 한 후 iOS에서 백그라운드 작업을 수행합니까?
UPDATE2 :
iOS 8에 도입 된 새로운 PushKit 프레임 워크를 사용하여이 작업을 수행 할 수 있습니다 . PushKit은 VoIP에 사용됩니다. 따라서 VoIP와 관련하여 사용하지 않으면 앱 거부 위험이 있습니다. ( 이 답변을 참조하십시오 ).
UDPDATE1 :
iOS8에 대한 설명서가 명확 해졌습니다 . 설명서는 여기에서 읽을 수 있습니다 . 관련 발췌문은 다음과 같습니다.
이 방법을 사용하여 앱에 대한 수신 원격 알림을 처리하십시오.
application:didReceiveRemoteNotification:
앱이 포 그라운드에서 실행될 때만 호출되는 메소드 와 달리 시스템은 앱이 포 그라운드 또는 백그라운드에서 실행될 때이 메소드를 호출합니다. 또한 원격 알림 백그라운드 모드를 사용하도록 설정 한 경우 푸시 알림이 도착하면 시스템에서 앱을 시작하거나 일시 중단 상태에서 해제하여 백그라운드 상태로 전환합니다. 그러나 사용자가 강제 종료 한 경우 시스템에서 자동으로 앱을 시작하지 않습니다. 이 경우 시스템이 앱을 자동으로 다시 시작하기 전에 사용자가 앱을 다시 시작하거나 장치를 다시 시작해야합니다.
WWDC 비디오에서는이를 명확하게 알 수 없지만 개발자 포럼에서 빠른 검색을 수행하면 다음과 같은 결과가 나타났습니다.
https://devforums.apple.com/message/873265#873265 (로그인 필요)
또한 앱 전환기에서 앱을 종료하면 (즉, 앱을 종료하기 위해 스 와이프하면) 푸시 알림이나 백그라운드 가져 오기에 관계없이 OS가 앱을 다시 시작하지 않습니다. 이 경우 사용자는 앱을 수동으로 다시 시작한 다음 그 시점부터 백그라운드 활동이 호출됩니다. - pmarcos
그 게시물은 Apple 직원이 작성한 것이므로이 정보가 정확하다는 것을 믿을 수 있다고 생각합니다.
따라서 스 와이프하여 앱 전환기에서 앱이 종료되면 예정된 백그라운드 페치에서도 앱이 시작되지 않습니다.
"구성표 관리"에서 대상의 시작 설정을로 변경할 수 있습니다 Wait for <app>.app to be launched manually
. 중단 점을 설정 application: didReceiveRemoteNotification: fetchCompletionHandler:
하고 푸시 알림을 보내 백그라운드 시작을 트리거하여 디버그 할 수 있습니다 .
문제가 해결 될지 확실하지 않지만 지금은 디버깅에 도움이 될 수 있습니다.
대답은 예이지만 '배경 가져 오기'또는 '원격 알림'을 사용해서는 안됩니다. PushKit은 당신이 원하는 답입니다.
요약하면 iOS 8의 새로운 프레임 워크 인 PushKit은 새로운 푸시 알림 메커니즘으로, 앱 전환기에서 스 와이프하여 앱이 종료 되어도 앱이 종료 된 경우에도 시각적 경고 메시지없이 백그라운드에서 자동으로 앱을 시작할 수 있습니다. 앱 스위처에서.
Apple의 PushKit 참조 :
The PushKit framework provides the classes for your iOS apps to receive pushes from remote servers. Pushes can be of one of two types: standard and VoIP. Standard pushes can deliver notifications just as in previous versions of iOS. VoIP pushes provide additional functionality on top of the standard push that is needed to VoIP apps to perform on-demand processing of the push before displaying a notification to the user.
To deploy this new feature, please refer to this tutorial: https://zeropush.com/guide/guide-to-pushkit-and-voip - I've tested it on my device and it works as expected.
Actually if you need to test background fetch you need to enable one option in scheme:
Another way how you can test it:
Here is full information about this new feature: http://www.objc.io/issue-5/multitasking.html
I've been trying different variants of this for days, and I thought for a day I had it re-launching the app in the background, even when the user swiped to kill, but no I can't replicate that behavior.
It's unfortunate that the behavior is quite different than before. On iOS 6, if you killed the app from the jiggling icons, it would still get re-awoken on SLC triggers. Now, if you kill by swiping, that doesn't happen.
It's a different behavior, and the user, who would continue to get useful information from our app if they had killed it on iOS 6, now will not.
We need to nudge our users to re-open the app now if they have swiped to kill it and are still expecting some of the notification behavior that we used to give them. I'm worried this won't be obvious to users when they swipe an app away. They may, after all, be basically cleaning up or wanting to rearrange the apps that are shown minimized.
This might help you
In most cases, the system does not relaunch apps after they are force quit by the user. One exception is location apps, which in iOS 8 and later are relaunched after being force quit by the user. In other cases, though, the user must launch the app explicitly or reboot the device before the app can be launched automatically into the background by the system. When password protection is enabled on the device, the system does not launch an app in the background before the user first unlocks the device.
For **iOS13**
For background PUSHES in iOS13 you must set below parameters
apns-priority = 5
apns-push-type = background
Required for WatchOS
Highly recommended for Other platforms
'Programing' 카테고리의 다른 글
CTE (Common Table Expression)를 사용하는 경우 (0) | 2020.04.26 |
---|---|
JavaScript에서 마우스 오른쪽 버튼 클릭 이벤트를 캡처하려면 어떻게해야합니까? (0) | 2020.04.26 |
getDefaultSharedPreferences와 getSharedPreferences의 차이점 (0) | 2020.04.26 |
로컬 저장소에서 원격 Git 저장소를 작성하는 방법은 무엇입니까? (0) | 2020.04.26 |
O (n)에서 길이 n의 정렬되지 않은 배열에서 k 번째로 큰 요소를 찾는 방법은 무엇입니까? (0) | 2020.04.26 |