1

I am using One Signal to send push notifications. However, if the notification content body contains only numbers it is not displayed.

The phone vibrates and even the badge number increases as expected but nothing displays. It happens both on iOS 9 and 10.

If I log the content I can see the numbers so it comes through perfectly but it doesn't display.

Any ideas what could be causing this?

Balázs Vincze
  • 3,550
  • 5
  • 29
  • 60
  • Two things. 1. The payload should look like this `{"aps":{"badge":3}}` 2. Settings to show badge for the app should be turned on. – iphonic Feb 07 '17 at 18:15
  • I think you misunderstood my question. I can increase the badge number thats not a problem. However if the body of the notification is a string containing only numbers it doesn't display. – Balázs Vincze Feb 07 '17 at 18:17
  • So you have confirmed that the exact same code works and displays the local notification if any alpha characters are included? – wottle Feb 07 '17 at 18:57
  • @wottle Yes, please see my answer – Balázs Vincze Feb 09 '17 at 08:57

2 Answers2

3

Okay, so here is my solution:

I do not know if it is a OneSignal bug or an iOS bug but it seems as if the notification only contains a content value with numbers only, it won't show. The phone vibrates, but nothing shows up.

Make sure you include something in your title field as well (these can be numbers only), and then your notification with a number only content will display properly.

Hope this helps someone!

Balázs Vincze
  • 3,550
  • 5
  • 29
  • 60
0

You will need to handle the notification from app delegate file and show the message. You should get the complete notification body within user info parameter of didReceiveRemoteNotification method of AppDelegate. You will need to retrieve the info from it and show alert.

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

    println("Recived: \(userInfo)")
   //Parsing userinfo:
   var temp : NSDictionary = userInfo
   if let info = userInfo["aps"] as? Dictionary<String, AnyObject> 
            {
                var alertMsg = info["alert"] as! String
                var alert: UIAlertView!
                alert = UIAlertView(title: "", message: alertMsg, delegate: nil, cancelButtonTitle: "OK")
                alert.show()
            }
} 

Reference From: https://stackoverflow.com/a/30508985/905517

Community
  • 1
  • 1
A J
  • 605
  • 4
  • 16