Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase自定义声音通知与Xamrin表单可用于IOS,但不';应用程序未运行时,无法使用android_Android_.net_Firebase_Xamarin_Xamarin.forms - Fatal编程技术网

Firebase自定义声音通知与Xamrin表单可用于IOS,但不';应用程序未运行时,无法使用android

Firebase自定义声音通知与Xamrin表单可用于IOS,但不';应用程序未运行时,无法使用android,android,.net,firebase,xamarin,xamarin.forms,Android,.net,Firebase,Xamarin,Xamarin.forms,我到处都找遍了,尝试了很多解决方案,但都没有成功。我正在使用API向我的应用程序(Android/IOS)发送通知,其中包含已包含在我的应用程序文件中的自定义声音文件。即使应用程序已关闭,IOS的声音也能正常工作,但在应用程序在后台运行之前,Android的声音无法正常工作。 下面是我使用的JSON { to = deviceId, priority = "high", content_available = true, notification = new { bo

我到处都找遍了,尝试了很多解决方案,但都没有成功。我正在使用API向我的应用程序(Android/IOS)发送通知,其中包含已包含在我的应用程序文件中的自定义声音文件。即使应用程序已关闭,IOS的声音也能正常工作,但在应用程序在后台运行之前,Android的声音无法正常工作。 下面是我使用的JSON

{
  to = deviceId,
  priority = "high",
  content_available = true,
  notification = new
   {
   body = englishMessage,
   title = title,
   badge = 1,
   content_available = true
   },
   android = new
    {
    ttl="86400s",
    priority= "high",
    notification = new
     {
      sound = SoundFileName,
     },
    },
     apns = new
     {
      payload = new
      {
       aps = new
       {
        sound = SoundFileName,
        content_available = true,
        badge = 1,
       },
      },
      customKey = "test app",
     }
  }

当你的应用程序在前台时,通知是由你手动生成的,这意味着你需要手动将此声音添加到通知中,因此你所做的是

var soundUri = Android.Net.Uri.Parse(pathToPushSound);
然后在通知管理器中添加以下方法

     var notiManager= Notification.Builder(context)
                                  .SetSound(soundUri) ...

你好@FreakyAli,非常感谢你的回答,是的,当应用程序在后台工作时,我可以播放任何声音,但我真正需要的是在应用程序关闭时播放自定义声音。我可以在IOS中这样做,但在android中,当你的应用程序处于死机状态时,它不起作用?是的,没错,当前在IOS上,当我发送通知时,我可以从api播放自定义声音,但是我不能在android上做这件事。你试过从通知频道设置声音吗?我说的是android通知频道,而不是json:当应用程序在后台时,通知是否显示在android屏幕上?或者你试过使用默认的声音吗?嗨,Lucas Zhang-MSFT,是的,它会显示在屏幕上,我只面对自定义声音的问题。你可以将问题发布到谷歌官方论坛。