ios - Send a push notification from a user to another using parse -


in application notification sent using parse when user request buy user. notification sent parse doesn't sent user(the receiver)! tried send notification parse website directly , received. can see in image below (a screenshot notification on parse) push sent=1 when send parse website , push sent= 0 when send code. tried many times don't know wrong code (unfortunately need 10 reputatuin post image)

here code:

            var pushquery:pfquery = pfinstallation.query()             pushquery.wherekey("user", equalto: self.recipientobjectid)              let data = [                 "alert" : "username requested buy item",                 "itemid" : "kotjr9dyge"]              var push:pfpush = pfpush()             push.setquery(pushquery)             push.setdata(data)              push.setmessage("username requested buy item")              push.sendpushinbackgroundwithblock({                 (issuccessful: bool, error: nserror!) -> void in                 println(issuccessful)              }) 

and in appdelegate:

func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { let notficationtypes:uiusernotificationtype = uiusernotificationtype.sound | uiusernotificationtype.alert | uiusernotificationtype.badge let notficationsettings:uiusernotificationsettings = uiusernotificationsettings(fortypes: notficationtypes, categories: nil)  uiapplication.sharedapplication().registerusernotificationsettings(notficationsettings) return true}  func application(application: uiapplication, didregisterusernotificationsettings notificationsettings: uiusernotificationsettings) { uiapplication.sharedapplication().registerforremotenotifications()}  func application(application: uiapplication, didregisterforremotenotificationswithdevicetoken devicetoken: nsdata) { var currentinstallation:pfinstallation = pfinstallation.currentinstallation() currentinstallation.setdevicetokenfromdata(devicetoken) currentinstallation.save() }  func application(application: uiapplication, didfailtoregisterforremotenotificationswitherror error: nserror) { println(error.localizeddescription)} func application(application: uiapplication, didreceiveremotenotification userinfo: [nsobject : anyobject]) { var notification:nsdictionary = userinfo["aps"] as! nsdictionary if (notification["content-available"] != nil){     if notification.objectforkey("content-available")!.isequaltonumber(1){         nsnotificationcenter.defaultcenter().postnotificationname("reloadtimeline", object: nil)     } }else{     pfpush.handlepush(userinfo) }   } 

go settings page app in parse dashboard. in push notifications sections, there's option called "client push enabled?". make sure switched on.

edit: actual problem seems you're creating push query user object id rather actual pfuser object, what's stored in database. try instead. i'm no @ swift might not correct syntax-wise.

var user:pfuser = pfquery.getuserobjectwithid(self.recipientobjectid) var pushquery:pfquery = pfinstallation.query() pushquery.wherekey("user", equalto: user) 

then continue code had previously.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -