Извините, что перепостил этот вопрос, как его задавали несколько раз, но для меня не было никакого ответа. Мое приложение больше не просыпается при фоновом уведомлении. Поэтому я обновил свой сценарий php и добавил поле HEADERs, как описано здесь и здесь Но не повезло.
Вот мой пример кода:
<?php
$device_token = 'd98e1d488acac56305a9f83b...b616bc5b5b3bf238dc';
//$device_token = '27b296397f81f48590a....fe2742e0b2a051ae2cefffded85d7';
// Put your private key's passphrase here:
$pem_secret = '';
$pem_file = 'pushcert.pem';
$url = "https://api.development.push.apple.com/3/device/$device_token";
//$body = '{"aps":{"alert":"balbla","badge":0,"sound":"default"}}';
$body = '{"aps":{"content-available":1},"acme1":"bar"}';
$header = ['apns-topic'=>'com.blabla.bla',
'apns-push-type'=>'background',
'apns-priority'=>'5'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_SSLCERT, $pem_file);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $pem_secret);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$information = curl_getinfo($ch);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
//On successful response you should get true in the response and a status code of 200
//A list of responses and status codes is available at
//https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH107-SW1
//var_dump($header);
//var_dump($information);
var_dump($response);
var_dump($httpcode);
?>
Я никогда не ввожу метод iOS, чтобы перехватить это уведомление:
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[[NSUserDefaults standardUserDefaults] setValue:userInfo forKey:@"testtesttest"];
// Method called when user click on notification and application is in background
application.applicationIconBadgeNumber = 0;
NSLog(@"did received remote notification"); }
Также в консоли моего устройства кажется, что устройство отменяет мои уведомления или что-то в этом роде не получить ![enter image description here](https://i.stack.imgur.com/Lq8UN.png)
Кроме того, стандартные уведомления (не в фоновом режиме) работают нормально. тестирование iOS 13.3.1
Большое спасибо за любую помощь, которую вы можете получить.
Включен фоновый режим:
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>location</string>
<string>processing</string>
<string>remote-notification</string>
</array>
![enter image description here](https://i.stack.imgur.com/h2Zza.png)
Настройки приложения также настроены: ![enter image description here](https://i.stack.imgur.com/xVfHX.jpg)