Can't receive Firebase notifications unless app is active in the foreground.

I’m currently trying to use Firebase and the notifications-v2 plugin to have my iOS app receive notifications when sent via the Firebase console.

I currently have it set up with my GoogleService-Info.plist, and have set my main.lua, build.settings and config.lua as they should be as far as I’m aware.

I have also noticed others with this problem had issues with their APNs certificates, but I have triple-checked mine and they are as they should be.

If anyone can suggest the issue it would be really helpful. I may have just set it up wrong as this is my first time using Firebase with Corona.

My files are below.

main.lua:

[lua]display.setStatusBar( display.HiddenStatusBar )

local storyboard = require(“composer”)

local notifications = require( “plugin.notifications.v2” )

notifications.registerForPushNotifications( { useFCM=true } )

notifications.subscribe( “topics/news” )

local function notificationListener( event )

    if ( event.type == “remote” ) then

        native.showAlert(‘Event:’, event.type)

    end

end

Runtime:addEventListener(‘notification’, notificationListener)

storyboard.gotoScene(“menu”)[/lua]

build.settings:

[lua]settings =

{

orientation =

{

    – Supported values for orientation:

    – portrait, portraitUpsideDown, landscapeLeft, landscapeRight

default = “portrait”,

supported = { “portrait”, },

},

 

– Android section

android =

{

usesPermissions =

{

“android.permission.INTERNET”,

},

},

 

– iOS section

iphone =

{

plist =

{

UIStatusBarHidden = false,

UILaunchStoryboardName = “LaunchScreen”,

CFBundleIconFiles =

{

“Icon-40.png”,

“Icon-58.png”,

“Icon-76.png”,

“Icon-80.png”,

“Icon-87.png”,

“Icon-120.png”,

“Icon-152.png”,

“Icon-167.png”,

“Icon-180.png”,

},

UIBackgroundModes = { “remote-notification” },

FirebaseAppDelegateProxyEnabled = false,

},

},

 

– Plugins section

plugins =

{

[“plugin.notifications.v2”] =

{

publisherId = “com.coronalabs”

},

},

 

– Project section

excludeFiles =

{

– Exclude unnecessary files for each platform

ios = { “Icon.png”, “Icon-*dpi.png”, },

android = { “Icon.png”, “Icon-??.png”, “Icon-???.png”, “LaunchScreen.storyboardc”, },

},

}[/lua]

config.lua:

[lua]application =

{

content =

{

width = 320,

height = 480, 

scale = “adaptive”,

fps = 60,

},

notification =

{

iphone =

{

types =

{

“badge”,

“sound”,

“alert”

},

},

},

}

[/lua]