Not receiving push notifications on unity IOS while application is opened

0 votes

We are integrating push notifications in our game but we are facing this problem. If the game is backgrounded we receive those push notifications but not while opened. This is the method we are using for it:

void onPushNotificationsReceived(string pushMessageString)
    {
       
        Console.WriteLine("onPushNotificationsReceived....Called");
 
        if (pushMessageString.EndsWith("comprando"))
        {
            GameObject.Find("SaveGame").GetComponent<DataUpload>().Coroutines(5);
            PushActualizando();
        }
        else if (pushMessageString.EndsWith("actualizando"))
        {
            GameObject.Find("SaveGame").GetComponent<DataUploadAmigo>().DownloadD("OfertaDeObjetos");
        }
        else if (pushMessageString.EndsWith("visitando"))
        {
            string aux = "visitando";
            string personaAnadir = pushMessageString.Remove(pushMessageString.Length - aux.Length);
            lista.Add(personaAnadir);
 
        }
        else if (pushMessageString.EndsWith("saliendo"))
        {
            string aux = "saliendo";
            string personaQuitar = pushMessageString.Remove(pushMessageString.Length - aux.Length);
            lista.Remove(personaQuitar);
        }
 
        //dump you code here
        Debug.Log(pushMessageString);
    }
 
We think we are not entering this method because there is no message appearing on the Debug console.
 
Any kind of help would be mean so much. Thanks
asked Oct 14, 2016 in Unity by spotify17 (16 points)

1 Answer

+1 vote
 
Best answer

Hi,

It could be a case when "setListenerGameObject(this.gameObject.name);" is not called properly and hence listener is not set. You can also check "App42PushHandlerInternal.m" class in the xcode project under ios plugin. You can put logs in "app42RunTimeDidReceiveRemoteNotification" method of the above class to know if this method is called or not when you have received push while app is in foreground.

You can also share the complete xcode console logs in case this issue. It will help us to understand the problem you are facing.

Regards,

Rajeev Ranjan

answered Oct 17, 2016 by rajeev.etc (1,660 points)
selected Oct 17, 2016 by spotify17
Okay, sorry for not realizing that you had answered us earlier. We are ready to send a push notification. Do we go for it?
sure, you can send the notification now.
We have done 2 pushes, the first one with the app in foreground, it didn´t appear in the xcode logs, the second one with the app in background, it appeared the notification and we could open the game from it.
Is it possible that you can test the sample provided by us on Unity with version 5.4.0f3 as it is working fine at my end with this version of unity. I will also try to test the sample with your version of unity at my end. I will update you as soon as I will complete my testing.
We have tested it on 5.4.0f3 and it is working perfectly. So it had to do with the unity version. Thank you for the help
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...