#Push Notification background updates Apple

32 messages · Page 1 of 1 (latest)

stone storm
#

Hi , I was try to implement push notification on background updates. I get working a push. But once I try background task for example output a test log message on Xcode it won’t work. Could some one help ? Should I post AppDelegate.swift file ?

inner dew
stone storm
#

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" }

#

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.

inner dew
stone storm
inner dew
stone storm
#

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.

inner dew
stone storm
#

I dont know how to do 😦 I see that that general push really great work but that background updates not

inner dew
stone storm
#

OK understood how you mean. I was think you know where could be the issue.

inner dew
stone storm
#

no that I not see but visual I see on phone that she arrive

inner dew
stone storm
#

I send Push see visual that push arrive but on background like that "🔥 PUSH EINGEGANGEN - STARTET VERARBEITUNG" i not see on xcode

inner dew
stone storm
#
: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
inner dew
stone storm
#

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.

inner dew
stone storm
#

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.

inner dew
stone storm
#

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.

inner dew
#

Do you have background push working app working directly with APNS (without Appwrite)?

stone storm
#

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.

stone storm
#

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.