#Push Notification background updates Apple
32 messages · Page 1 of 1 (latest)
Sure. Please also share your code for sending the push notification
And it would be good to check to see if there are any logs from the provider
Hi,
that is my demo php call:
// Fehlerausgabe aktivieren
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Nur die wirklich benötigten Appwrite-Klassen einbinden
require_once __DIR__ . '/Appwrite/AppwriteException.php';
require_once __DIR__ . '/Appwrite/Client.php';
require_once __DIR__ . '/Appwrite/Service.php';
require_once __DIR__ . '/Appwrite/Services/Messaging.php';
use Appwrite\AppwriteException;
use Appwrite\Client;
use Appwrite\Service;
use Appwrite\Services\Messaging;
// Funktion zur Generierung einer zufälligen Message-ID
function generateMessageId($length = 20) {
return substr(str_shuffle(str_repeat('abcdefghijklmnopqrstuvwxyz0123456789', ceil($length/36))), 0, $length);
}
try {
$client = new Client();
$client
->setEndpoint('https://cloud.appwrite.io/v1')
->setProject('6***1')
->setKey('standard_d***8')
;
$messaging = new Messaging($client);
$result = $messaging->createPush(
messageId: generateMessageId(),
title: 'Test-Titel',
body: 'Test-Inhalt',
topics: ["6***c"],
users: ["6***5"],
targets: ["6***0"],
data: [
"type" => "background_task_one",
"lastSyncId" => generateMessageId()
],
action: null,
icon: null,
sound: null,
color: null,
tag: null,
badge: null,
contentAvailable: true,
critical: false,
priority: null,
draft: false,
scheduledAt: null
);
// Ergebnis ausgeben
echo "Push-Nachricht erfolgreich gesendet:\n";
var_dump($result);
} catch (AppwriteException $e) {
echo "Appwrite Fehler: " . $e->getMessage() . "\n";
echo "Fehler Code: " . $e->getCode() . "\n";
if ($e->getResponse()) {
echo "Response: " . json_encode($e->getResponse(), JSON_PRETTY_PRINT) . "\n";
}
} catch (Exception $e) {
echo "Allgemeiner Fehler: " . $e->getMessage() . "\n";
}```
Once I send I get such success message:
Push-Nachricht erfolgreich gesendet: array(13) { ["$id"]=> string(20) "17kiz45btx6rj8n2fhuo" ["$createdAt"]=> string(29) "2025-01-23T17:52:26.845+00:00" ["$updatedAt"]=> string(29) "2025-01-23T17:52:26.845+00:00" ["providerType"]=> string(4) "push" ["topics"]=> array(1) { [0]=> string(20) "6***c" } ["users"]=> array(1) { [0]=> string(20) "6***5" } ["targets"]=> array(1) { [0]=> string(20) "6**0" } ["scheduledAt"]=> NULL ["deliveredAt"]=> NULL ["deliveryErrors"]=> array(0) { } ["deliveredTotal"]=> int(0) ["data"]=> array(5) { ["title"]=> string(10) "Test-Titel" ["body"]=> string(11) "Test-Inhalt" ["data"]=> array(2) { ["type"]=> string(19) "background_task_one" ["lastSyncId"]=> string(20) "485vetw39o07cqrkp2dz" } ["contentAvailable"]=> bool(true) ["priority"]=> string(4) "high" } ["status"]=> string(10) "processing" }
My appdelegate.swift :
That is my flutter part of this...
But as I told I not understood why he not display the demo message like: 🔄 Führe Background Task aus if that task submit background_task_one.
FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting).
That I now was edit and will take care about this in future. 🙂
You only have a flutter app? Not native? Is your provider APNS directly or through FCM
I only use that flutter app and place also code into AppDelegate.swift. The APNS I use directly. It also show that notification. it is only the background update who is not work.
Maybe you can use some package to help with handling the push notification like https://pub.dev/packages/awesome_notifications#-configuring-ios-for-awesome-notifications
Then, I would see if I can trigger background notifications directly with apple. Then, try in Appwrite
I dont know how to do 😦 I see that that general push really great work but that background updates not
How to do what?
The problem is you're not sure where the problem is. It could be your code so to narrow it down, it helps to test with something that works
OK understood how you mean. I was think you know where could be the issue.
did you see "🔥 PUSH EINGEGANGEN - STARTET VERARBEITUNG" log when the app was in the background?
no that I not see but visual I see on phone that she arrive
what do you mean?
I send Push see visual that push arrive but on background like that "🔥 PUSH EINGEGANGEN - STARTET VERARBEITUNG" i not see on xcode
hmm..ya im not sure. maybe something with your config. best to try to start with something simple. like even a demo app that has background push
:mobile_phone: App wurde aktiv
:bell: PUSH DETAILS:
:package: UserInfo: [AnyHashable("aps"): {
alert = {
body = "Test-Inhalt";
title = "Test-Titel";
};
"content-available" = 1;
data = {
lastSyncId = q7mxjsl5ibpe2d98rzoh;
type = "background_task_one";
};
}, AnyHashable("headers"): {
"apns-priority" = 10;
}]
:package: DATA: Keine DATA
:package: APS: {
alert = {
body = "Test-Inhalt";
title = "Test-Titel";
};
"content-available" = 1;
data = {
lastSyncId = q7mxjsl5ibpe2d98rzoh;
type = "background_task_one";
};
}
:no_bell: Silent Push - prüfe auf background_task_one
:arrows_counterclockwise: Background Task One gefunden
:white_check_mark: Background Task an Flutter gesendet
flutter: Received method call: handleBackgroundTask
flutter: Received background task: {lastSyncId: q7mxjsl5ibpe2d98rzoh, type: background_task_one}
flutter: Verarbeite Background Task One...
flutter: Last Sync ID: q7mxjsl5ibpe2d98rzoh```
That is my output. Once app on foreground i see and if on background I not any see
ya im not sure if that's by design or not
I not get it work. I only can provide my demo app. It seems strange. On firebase it is easy they provide even a flutter plugin for messaging.
You said you were using APNS directly and not FCM 🧐
I know we are using APNS directly. I want tell that if implement firebase messaging it is great because firebase provide a plugin on flutter dev who fully support communication between swift and flutter.
I now was talk to many developers who I know all tell me the same that this background push bot is working until now.
If you want to use FCM, you can use the flutter package with Appwrite using the FCM provider
I not want use FCM. I choose Appwrite because you support AppleAPN. 🙂 but I can’t get it work with background push. I even would pay for a solution that some one can fix my demo app.
I now was talk to many developers who I know all tell me the same that this background push bot is working until now.
What do you mean?
Do you have background push working app working directly with APNS (without Appwrite)?
I was ask some of my developers if they can solve the issue to receive the background task on my demo app. No one can made it work. Once I send a push with background task thorough Appwrite that demo app not start that task. Normal push are work.
I not was try this. Then I not need use Appwrite if I am develop that feature.
Maybe here will be some developer read who can help me. I can share the demo app and also can pay for it that I get a working demo.