Einzelnen Beitrag anzeigen

knaeuel

Registriert seit: 2. Jul 2007
110 Beiträge
 
Delphi 10.3 Rio
 
#2

AW: Von angezeigter Notification zum Programm wechseln?

  Alt 29. Jun 2018, 12:10
ich poste mal einfach etwas Quellcode. Der fett gedruckte Teil ist das, was du suchst.

Delphi-Quellcode:
procedure TFormX.HandleAlert;
var //Notifications:
    MyNotification:TNotification;
begin
  MyNotification:=NotificationCenter1.CreateNotification;
  MyNotification.Name:='Message'; //taucht auf Android nicht auf
  MyNotification.Title:='Notification'; //Taucht als Titelzeile (fett) auf
  //AlertBody ist für iOS obligatorisch
  MyNotification.AlertBody:='Alarmmeldung!'; //taucht als 2. Zeile (nicht fett) auf
  MyNotification.Number:=usercfg.n_notifications; //funktioniert i-wie nicht wie erwartet
  MyNotification.EnableSound:=false;

  {$IFDEF iOS}
  //nur für iOS?
  NotificationCenter1.ApplicationIconBadgeNumber:=usercfg.n_notifications;
  {$ENDIF}
hier die beiden Zeilen, die für dich hauptsächlich interessant sind:
Delphi-Quellcode:
  //beim Klicken auf die Notification soll sich die App öffnen:
  MyNotification.HasAction := True;
  MyNotification.AlertAction := 'Open App';
und noch der Rest der Procedure
Delphi-Quellcode:
  //ZUM SCHLUSS ABSCHICKEN

  //Anzeige mit gesetztem Firedate
  //z.B. Fired in 10 seconds: MyNotification.FireDate := Now + EncodeTime(0, 0, 10, 0);
  //MyNotification.FireDate:=now;
  //NotificationCenter1.ScheduleNotification(MyNotification);

  //sofortige Anzeige
  try
    NotificationCenter1.PresentNotification(MyNotification);
  finally
    MyNotification.DisposeOf;
  end;
end;
Ich hoffe, es hilft und funzt
Wolfgang

Geändert von knaeuel (29. Jun 2018 um 12:15 Uhr) Grund: fett innerhalb code funzt nicht
  Mit Zitat antworten Zitat