AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Cross-Platform-Entwicklung Notifications mit individuellem Sound
Thema durchsuchen
Ansicht
Themen-Optionen

Notifications mit individuellem Sound

Ein Thema von bcvs · begonnen am 8. Mär 2024 · letzter Beitrag vom 29. Jun 2024
Antwort Antwort
Seite 1 von 2  1 2      
Kai_in_HH

Registriert seit: 25. Jun 2008
Ort: Hamburg
59 Beiträge
 
Delphi 11 Alexandria
 
#1

AW: Notifications mit individuellem Sound

  Alt 11. Mai 2024, 10:32
Es wäre schön, wenn du den Link zum Ticket hier posten könntest.
Dann können wir es ggf. verfolgen, kommentieren (falls uns noch was hilfreiches dazu einfällt) usw...
Gute Idee...in der Hoffnung, dass das Ticket "öffentlich lesbar" ist.

https://embt.atlassian.net/servicede...rtal/1/RSS-887
Kai
formerly known as linus_wildcat
  Mit Zitat antworten Zitat
bcvs

Registriert seit: 16. Jun 2011
733 Beiträge
 
Delphi 12 Athens
 
#2

AW: Notifications mit individuellem Sound

  Alt 13. Mai 2024, 16:37
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:
I must stay there isn't a lot of information on this either in the Android documentation or online so here are the important points.

1) sound needs to be from presented as "content://" it be to make is shareable with the external OS to play the notification sound., because the notification is set up using an Intent and that means the it has to be a shareable URI.

2) the sound can only be set at the channel level AND when the channel is created, so the default channel will always have the default sound. So to have new sound you have to set it at when a new channel is created.
3) Setting the sound at the notification level has been deprecated in Android 7 or 8, that sound is not used at all. (I learnt this from the looking at the Android source)
4) I have modified your code so I could figure out how the notifications work, but it all boils down to a simple function to get the file URI, and to use the file URI you need to need to specify secure file sharing in the entitlements list, in the project options, this will give you the ability to use the file provider.
So läuft's bei mir:
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;
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.392 Beiträge
 
Delphi 12 Athens
 
#3

AW: Notifications mit individuellem Sound

  Alt 13. Mai 2024, 17:23
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');
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
Kai_in_HH

Registriert seit: 25. Jun 2008
Ort: Hamburg
59 Beiträge
 
Delphi 11 Alexandria
 
#4

AW: Notifications mit individuellem Sound

  Alt 13. Mai 2024, 20:34
@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:
  NotificationChannel.SoundName:= GetFileUriStr(TPath.Combine(TPath.GetDocumentsPath, 'bell.mp3'));
der Prozedur CreateDefaultNotificationChannel die Fehlermeldung, dass es die Funktion im Objekt TChannel nicht gibt.

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?
Kai
formerly known as linus_wildcat

Geändert von Kai_in_HH (13. Mai 2024 um 21:26 Uhr)
  Mit Zitat antworten Zitat
bcvs

Registriert seit: 16. Jun 2011
733 Beiträge
 
Delphi 12 Athens
 
#5

AW: Notifications mit individuellem Sound

  Alt 14. Mai 2024, 07:33
Was gibt es bei dir nicht? Das Feld Soundname? Würde mich schon sehr wundern.
  Mit Zitat antworten Zitat
Kai_in_HH

Registriert seit: 25. Jun 2008
Ort: Hamburg
59 Beiträge
 
Delphi 11 Alexandria
 
#6

AW: Notifications mit individuellem Sound

  Alt 14. Mai 2024, 07:45
Was gibt es bei dir nicht? Das Feld Soundname? Würde mich schon sehr wundern.
Genau. E2003: Undeklarierter Bezeichner: 'Soundname' in ....

Strange, oder?
Kai
formerly known as linus_wildcat
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.660 Beiträge
 
Delphi 12 Athens
 
#7

AW: Notifications mit individuellem Sound

  Alt 14. Mai 2024, 08:45
Ich habe eben nachgesehen, das Feld wurde anscheinend erst mit Delphi 12 eingeführt.
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
Kai_in_HH

Registriert seit: 25. Jun 2008
Ort: Hamburg
59 Beiträge
 
Delphi 11 Alexandria
 
#8

AW: Notifications mit individuellem Sound

  Alt 28. Jun 2024, 22:27
Es wäre schön, wenn du den Link zum Ticket hier posten könntest.
Dann können wir es ggf. verfolgen, kommentieren (falls uns noch was hilfreiches dazu einfällt) usw...
Gute Idee...in der Hoffnung, dass das Ticket "öffentlich lesbar" ist.

https://embt.atlassian.net/servicede...rtal/1/RSS-887
Folks,

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?
Kai
formerly known as linus_wildcat
  Mit Zitat antworten Zitat
TurboMagic

Registriert seit: 28. Feb 2016
Ort: Nordost Baden-Württemberg
3.067 Beiträge
 
Delphi 12 Athens
 
#9

AW: Notifications mit individuellem Sound

  Alt 29. Jun 2024, 09:03
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:
https://www.embarcadero.com/support
Grüße
TurboMagic
  Mit Zitat antworten Zitat
Kai_in_HH

Registriert seit: 25. Jun 2008
Ort: Hamburg
59 Beiträge
 
Delphi 11 Alexandria
 
#10

AW: Notifications mit individuellem Sound

  Alt 29. Jun 2024, 09:52
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.
Kai
formerly known as linus_wildcat
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:00 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