Sending Custom Notifications in Unity iOS

0 votes

How can I send a custom iOS push notification through script in unity. I am trying to send additional data like room Ids and links. I tried using a dictionary like u have done with hashmaps for the android example here

  1. String userName = "Nick";  
  2. HashMap< String,String> message = new HashMap< String,String>();  
  3. message.put("alert""Hello! This is my first notification.");  
  4. message.put("badge""1"); //Applicable for iOS only  
  5. message.put("sound""default"); //Applicable for iOS only  
  6. message.put("sendingFrom""Android"); //This is Custom application key  

but i get an error.

asked Oct 17, 2015 in App42PaaS & BPaaS by jibran (10 points)

1 Answer

0 votes
Hello Jibran,

Could you please share the exception message which you are getting in your editor console? It will help us to provide better support to you.

Regards,

Himanshu Sharma
answered Oct 18, 2015 by hs00105 (1,915 points)
No exception. Project fails to sun. It doesnt even show the error in the console. Just "all errors have to be fixed before running the project"
Hello Jibran,

Please find a below code snippet and let me know if it helps:

String message = "{\"alert\":\"Hello! This is my first notification.\",\"badge\":\"1\",\"sound\":\"default\",\"sendingFrom\":\"Android\"}";
String userName = "Nick";
App42Log.SetDebug(true);        //Print output in your editor console
pushNotificationService.SendPushMessageToUser(userName,message, new UnityCallBack());
public class UnityCallBack : App42CallBack
{
    public void OnSuccess(object response)
    {
        PushNotification pushNotification = (PushNotification) response;  
        App42Log.Console("Message is " + pushNotification.GetMessage());
        App42Log.Console("userName is : " + pushNotification.GetMessage());
    }

    public void OnException(Exception e)
    {
        App42Log.Console("Exception : " + e);
    }
}

Regards,
Himanshu Sharma
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
Migrate from Parse to ShepHertz App42
...