Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   iOS TNotificationCenter: OnReceiveLocalNotification wird nicht ausgelöst (https://www.delphipraxis.net/198133-tnotificationcenter-onreceivelocalnotification-wird-nicht-ausgeloest.html)

uups 5. Okt 2018 18:01

TNotificationCenter: OnReceiveLocalNotification wird nicht ausgelöst
 
Hallo!

Ich ein Problem mit dem TNotificationCenter in einer iOS-App. Ich weise der OnReceiveLocalNotification eine Objekt-Methode zu, diese wird jedoch weder beim Erscheinen der Notification noch beim Tap darauf ausgelöst.

Delphi-Quellcode:
type
  TapIOSDeviceNotifications = class
  constructor Create;
  destructor Destroy; override;
  private
    [...]
  protected
    [...]
    procedure LocalNotificationReceived(Sender: TObject; ANotification: TNotification);
  public
    [...]
  end;

implementation

constructor TapIOSDeviceNotifications.Create;
begin
  inherited Create;
  NotificationCenter := TNotificationCenter.Create(nil);
  NotificationCenter.OnReceiveLocalNotification := LocalNotificationReceived;
end;

procedure TapIOSDeviceNotifications.LocalNotificationReceived(Sender: TObject; ANotification: TNotification);
begin
  WriteLog(ANotification.Name);
end;
Hat jemand eine Idee, woran es liegen könnte?

knaeuel 8. Okt 2018 13:57

AW: TNotificationCenter: OnReceiveLocalNotification wird nicht ausgelöst
 
Hi,

du schreibst vom Erscheinen der Notification. Erscheint sie wirklich oder meinst du nur das Auslösen?

Da bisher noch niemand geantwortet hat, schreibe ich einfach trotzdem, was mir dazu einfällt.

Auf iOS-Geräten muss die App im Hintergrund sein, damit Notifications ausgelöst werden.

Die Berechtigung muss gesetzt sein. Das machst du in der IDE unter Projekt -> Optionen -> Versionsinformationen. Dort muss der Schlüssel "FMLocalNotificationPermission" mit dem Wert "true" gefüttert werden.

Wenn alles richtig ist, wird die App beim ersten Start eine Benutzerbestätigung für die Berechtigung anfordern.

Vielleicht hilfts ja doch :) lg

himitsu 3. Feb 2022 16:06

AW: TNotificationCenter: OnReceiveLocalNotification wird nicht ausgelöst
 
Und hier wird auch nur das TNotificationCenter erstellt, aber noch TNotification erstellt und abgeschickt (PresentNotification/ScheduleNotification).


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:14 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz