Backendless Support
 
Waiting for user's response

ios push notifications only work sometimes

Hello,

I have an application that is essentially a park scheduling app. I have a iOS push notification setup to ask my users if they still plan on attending their booked park visit 15minutes before their visit. The problem is only 25% of the iOS push notifications actually show up on my device.

For example: If I'm going to the park at 9:00am, 12:30pm, 4:30pm, and 7:00pm I only end up getting notified for the 7:00pm visit at 6:45pm, but should get a notification for each visit.

Curiously, I have other iOS notifications setup to send me tips while I'm at the park and they almost always come through, but not the 15 minute reminder. Is there something I'm missing here?

Leave a Comment

Comments (3)

photo
1

Hi Austin

I have a question regarding message publishing. How are you scheduling push notifications to be delivered on 8:45AM, 12:15AM etc? Are messages being published from timer in Business Logic or you use delayed publishing or else? Please provide more details about the use case.

Reagrds Anton

photo
1

Hey Anton,

Sorry for the late reply. This is how we have setup this particular app notification. Please advise if there is something we've done wrong.

AppDelegate.swift:

@available(iOS 10.0, *)

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void){

if response.actionIdentifier == "Notification_ok" {

let alertController = UIAlertController(title: "Confirmation",

message: "Ok",

preferredStyle: .alert)

let defaultAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.default) { (result : UIAlertAction) -> Void in

}

alertController.addAction(defaultAction)

}

else if response.actionIdentifier == "Notification_confirm"{

let application = UIApplication.shared

if application.applicationState == UIApplicationState.active{

UserDefaults.standard.set("0", forKey: "isFromNotification")

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "deleteBooking"), object:"0", userInfo:response.notification.request.content.userInfo)

}else{

UserDefaults.standard.set("0", forKey: "isFromNotification")

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "deleteBooking"), object:"1", userInfo:response.notification.request.content.userInfo)

}

}else

{

}

completionHandler()

}

LoggedinViewController:

func handleModifyListNotification(_ notification:Notification)

{

var dicInfo = notification.userInfo! as Dictionary

let pkName = dicInfo["parkName"] as! String

let pkTime = dicInfo["time"] as! String

let objId = dicInfo["objectId"] as! String

if notification.object as! String == "1" {

self.deleteBooking(objId)

}

else

{

let alertController = UIAlertController(title: "Confirmation",

message: "Are You Still going to the \(pkName) at \(pkTime)?",

preferredStyle: .alert)

let defaultAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.default) { (result : UIAlertAction) -> Void in

self.deleteBooking(objId)

}

let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default) { (result : UIAlertAction) -> Void in

}

alertController.addAction(defaultAction)

alertController.addAction(okAction)

self.present(alertController, animated: true, completion: nil)

}

}

func handleShowPopUp(_ tmpDic:NSDictionary)

{

let APPDelegate = UIApplication.shared.delegate as! AppDelegate

APPDelegate.isFromNotication = false

let pkName = tmpDic["parkName"] as! String

let pkTime = tmpDic["time"] as! String

let objId = tmpDic["objectId"] as! String

DispatchQueue.main.async

{

let alertController = UIAlertController(title: "Confirmation",

message: "Are You Still going to the \(pkName) at \(pkTime)?",

preferredStyle: .alert)

let defaultAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.default) { (result : UIAlertAction) -> Void in

self.deleteBooking(objId)

}

let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default) { (result : UIAlertAction) -> Void in

}

alertController.addAction(defaultAction)

alertController.addAction(okAction)

self.present(alertController, animated: true, completion: nil)

}

}

photo
1

Hello Austin,

What version of iOS-SDK are you using?

Also, please check this documentation which shows how to use the different scenarios of publishing push notifications via iOS SDK (e.g. repeated publishing).

Reagards, Olga