![]() |
Notifications mit individuellem Sound
Hallo zusammen,
Mal wieder eine Frage zu Notifications: Ich möchte meinen Notifications einen individuellen Sound mitgeben. Wenn man die Dokumentation und verschiedene Forumsbeiträge liest, scheint das ja auch ganz einfach zu seien:
Delphi-Quellcode:
Aber wenn ich das so mache, nimmt Andrpoid immer noch den Standard-Sound und unter iOS höre ich überhaupt nichts.
Notification := NotificationCenter1.CreateNotification;
Notification.EnableSound:=true; Notification.SoundName:= MySoundfile; Auf beiden Platformen kann ich den Sound mit dem TMediaplayer abpielen lassen. So weiß ich, dass der Soundfile auf dem Handy angekommen ist und dass MySoundfile korrekt ist. Ich benutze ein mp3 untere Android und ein caf unter iOS: Delphi ist V12 Irgendwelche Ideen? |
AW: Notifications mit individuellem Sound
Gab es da nicht eine neue API (welche Delphi nicht nutzt)
und bei der alten API bestimmt nun das OS den Ton (und ignoriert deine Vorgabe) ? |
AW: Notifications mit individuellem Sound
Auch auf einem älteren Handy von 2018 mit Android 9 habe ich das selbe verhalten. Das verwendet ja wohl noch nicht diese neue API.
|
AW: Notifications mit individuellem Sound
Verdammte Axt, ich habe das gleiche Problem.
Ich stelle in assets\internal\ meine eigene mp3 bereit, sie wird aber nicht als Notification-Ton verwendet. Es kommt immer nur der Standard-Ton. Hier mein Code
Code:
ProgDir wird in einer anderen Funktion so ermittelt und funktioniert z.B. auch einwandfrei für die Arbeit mit meiner SQLLite-DB, daran kanns also nicht liegen
procedure TForm1.PresentNotificationClick(Sender: TObject);
var MyNotification: TNotification; begin MyNotification := NotificationCenter1.CreateNotification; try MyNotification.Name := 'BikeAppNotification'; MyNotification.AlertBody := 'BikeApp Notification'; MyNotification.FireDate := Now; MyNotification.EnableSound := True; MyNotification.SoundName := TPath.Combine(ProgDir, 'bell.mp3');; NotificationCenter1.PresentNotification(MyNotification); finally MyNotification.DisposeOf; end; end;
Code:
Also das ist nach allen Anleitungen eigentlich der richtige Weg. Interessiert nur meine App (oder den Delphi-Compiler?) nicht.
ProgDir := TPath.GetDocumentsPath;
Kai |
AW: Notifications mit individuellem Sound
Auf welcher Plattform?
Für Android steht z.B. etwas bezüglich setSound in der Hilfe. ![]() Wobei ich irgendwie das Gef+hl hab, als wenn Emba vergessen hat das hasUserSetSound zu implementieren? |
AW: Notifications mit individuellem Sound
Ups, sorry, ja, wir reden über Android.
Das Gefühl habe ich irgendwie auch. Komischerweise, wenn ich das Handy via USB am PC anschließe, sehe ich im Explorer unter \Interner Speicher\Android\data\com.embarcadero.BikeTracking App\files die mp3, die nicht gespielt wird. Aber die DB nicht, die einwandfrei bearbeitet werden kann. Maximale Verwirrung macht sich breit. Und soweit ich Deine Antwort begrüße, anfangen kann ich damit nix. Ich bin offiziell anerkannter Java-Hasser. Ich weiß, ein Widerspruch in sich, Java nicht mögen und für Android klöppeln...aber genau darum nehme ich ja Delphi. |
AW: Notifications mit individuellem Sound
Wobei Delphi unter Android intern auf diese Java-Funktionen zugreift.
|
AW: Notifications mit individuellem Sound
Weiß ich doch, dass Android ohne Java(-Sch*ss) nicht geht.
Aber mögen muss ich es deswegen nicht. Ich nehme halt Delphi damit ich mit dem Schrott nicht in Verbindung kommen muss. Aber erlebe halt immer wieder Hindernisse. Wobei ich nicht weiß, ob Embarcadero in einer nicht sauberen Implementierung daran Schuld ist, oder etwas anderes. Aber die Diskussion darüber löst nicht unser Problem... |
AW: Notifications mit individuellem Sound
Also unter windows würde ich sagen, dass kein mp3 für solche Sounds verwendet wird, sonden halt wav. Bei Android hab ich da aber keine Ahnung.
|
AW: Notifications mit individuellem Sound
Zitat:
hier ein Ticket erstellen: ![]() Dann sollte sich EMBT mal irgendwann des Themas annehmen. |
AW: Notifications mit individuellem Sound
Zitat:
Unter Android ist MP3 auch kein Problem, ich habe viele eigene kleine MP3s auf meinem Handy und als Ping für SMS, WhatsApp, Mail.....name it, you got it....eingestellt. |
AW: Notifications mit individuellem Sound
Zitat:
![]() |
AW: Notifications mit individuellem Sound
Anzeige ist raus ... ach Quatsch, ich meine Ticket ist eröffnet. 8-)
|
AW: Notifications mit individuellem Sound
UPDATE:
Habe meine Anwendung mal wieder für Windows kompiliert und auch hier kommt die Notification (unten rechts am Bildschirm), aber auch nicht mit meinem Ton, sondern das Standard-Palimpalim. |
AW: Notifications mit individuellem Sound
Zitat:
Dann können wir es ggf. verfolgen, kommentieren (falls uns noch was hilfreiches dazu einfällt) usw... |
AW: Notifications mit individuellem Sound
Zitat:
![]() |
AW: Notifications mit individuellem Sound
Sorry, ich hatte vergessen, meine Lösung hier zu posten.
Man muss das über einen Channel machen. Ich hatte dazu ein Ticket im Customer Support Portal eröffnet. Die Antwort: Zitat:
Delphi-Quellcode:
{$ifdef ANDROID}
const sChannelID = 'MyChannelID'; // to have a custom sound you HAVE to use custom channel // as the channel's sound is set at creation //this is crucial bit... // to use fileprovider you need to specify secure file sharing in the entitlements list function GetFileUriStr(const AFileName: string): string; var LFile: JFile; begin LFile := TJFile.JavaClass.init(StringToJString(AFileName)); Result := JStringToString(TAndroidHelper.JFileToJURI(LFile).toString); end; {$endif} procedure TdmNotification.CreateDefaultNotificationChannel; // wird vorab aufgerufen, z.B. im Create var NotificationChannel: TChannel; begin NotificationChannel := NotificationCenter.CreateChannel; NotificationChannel.Id := sChannelID; NotificationChannel.Title := 'Custom notification channel'; NotificationChannel.Description := 'Notification channel to test sound'; NotificationChannel.Importance := TImportance.High; // NOTE: This is a 'heads-up notification'. //the CONTENT URI string needs to be set here and will be used for the all THIS channel notifications NotificationChannel.SoundName:= GetFileUriStr(GetSoundFileName); NotificationCenter.CreateOrUpdateChannel(NotificationChannel); end; function TdmNotification.GetSoundFileName: string; begin {$IFDEF IOS} Result := 'mixkit-bell-notification-933.caf'; {$ELSE} Result := IncludeTrailingPathDelimiter(TPath.GetDocumentsPath) + 'mixkit-bell-notification-933.mp3'; {$ENDIF} end; procedure TdmNotification.CreateNotification(AlarmTime); var Notification: TNotification; begin Notification := NotificationCenter.CreateNotification; try Notification.Name :='MyNotification'; Notification.Title :='Test Notification Title'; Notification.AlertBody:='Test Notification with individual sound'; {$ifdef ANDROID} Notification.ChannelId := sChannelID; {$else} Notification.EnableSound:=true; Notification.SoundName:= GetSoundFileName; {$endif} Notification.FireDate:= AlarmTime; NotificationCenter.ScheduleNotification(Notification); finally Notification.Free; end; end; |
AW: Notifications mit individuellem Sound
Wenn man schon TPath benutzt, dann kann man auch gleich Weiteres davon verwenden.
Delphi-Quellcode:
Result := IncludeTrailingPathDelimiter(TPath.GetDocumentsPath) + 'mixkit-bell-notification-933.mp3';
Result := TPath.Combine(TPath.GetDocumentsPath, 'mixkit-bell-notification-933.mp3'); |
AW: Notifications mit individuellem Sound
@bcvs
Das wäre eigentlich genau das Beispiel, wonach ich gesucht habe, da gibts echt nicht viel, aber leider bekomme ich in der Zeile
Code:
der Prozedur CreateDefaultNotificationChannel die Fehlermeldung, dass es die Funktion im Objekt TChannel nicht gibt.
NotificationChannel.SoundName:= GetFileUriStr(TPath.Combine(TPath.GetDocumentsPath, 'bell.mp3'));
Kommentiere ich diese Zeile aus, lässt sich die App natürlich kompilieren, löst aber nicht das Problem. Und für Windows wird es gar nicht gelöst, da ja einige Funktionen / Befehle eh nur unter Android verfügbar sind. Und nu? Liegt es vielleicht daran, dass ich Delphi 11 CE verwende und nicht die Vollversion 12? |
AW: Notifications mit individuellem Sound
Was gibt es bei dir nicht? Das Feld Soundname? Würde mich schon sehr wundern.
|
AW: Notifications mit individuellem Sound
Zitat:
Strange, oder? |
AW: Notifications mit individuellem Sound
Ich habe eben nachgesehen, das Feld wurde anscheinend erst mit Delphi 12 eingeführt.
|
AW: Notifications mit individuellem Sound
Zitat:
|
AW: Notifications mit individuellem Sound
Zitat:
hat jemand Erfahrung damit, ob und wenn überhaupt, wie schnell die reagieren? Seit 10. Mai steht das Ticket auf "Ready for validation". Sprich: angekommen im Bug-Tracker, hat aber noch keiner angesehen. Also als ich noch bei Borland (ja, so hießen die 1988) gearbeitet habe, ging das schneller. Ein Anruf von einem Kunden, Problem nachgestellt und 2 Stunden später war die Mail an USA raus. Auf was warten die? Auf günstige Sonnenwinde oder das der Supportleiter bei Vollmond ein Einhorn melken konnte? |
AW: Notifications mit individuellem Sound
Hallo,
das erfassen eines Bugreports ist schon mal ein guter erster Schritt. Mal wird da schneller drauf reagiert, mal langsamer. Nur: über diesen Weg gibt's meist keine schnellen Lösungen. Aber: wenn du eine laufende Subskription hast, steht dir normalerweise noch ein weiterer Weg offen, bei dem sich jemand von EMBT dann tatsächlich persönlich bei dir meldet. Das führt auch immer wieder zu Fixes noch bevor diese im Produkt selbst drin sind. Zumindest hab' ich auch dem Weg schon Code erhalten und ein anderes mal noch Ideen was zu untersuchen wäre die dann zu einem Workaround geführt haben der für mich gangbar war. Der Weg ist hier zu erreichen: ![]() |
AW: Notifications mit individuellem Sound
Moin zusammen.
Mir ist natürlich bewusst, dass ich bei einer kostenlosen Software (Delphi CE) eingeschränkten Support habe und ich erwarte auch nicht, dass sich jemand "persönlich" bei mir meldet. Aber 6 Wochen ein Ticket ungeöffnet liegen lassen geht auch nicht. Finde ich. Aber ich bin ja noch jung und kann warten. |
AW: Notifications mit individuellem Sound
Die haben nochmal ein internes BugReportSystem ... und den Kunden wird fast nie gesagt, wie es da drin aussieht.
Kommt die nächste Version raus, werden schlagartig viele Tickest auf Bearbeitet umgestellt und man kann den Bugfix mit der neuen Version kaufen. :thumb: |
AW: Notifications mit individuellem Sound
Hallo,
hätte ich Berechtigung das Ticket zu sehen, würde ich mir das mal durchlesen und an passender Stelle bei EMBT darauf aufmerksam machen, dass da evtl. was durch die Lappen ging. => ich kann das leider nicht anzeigen. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:15 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz