iphone - How to add an action to notifications in Swift 2 iOS 9 -
i'm trying button in notifications send php apns http://immobiliare.github.io/apnsphp/html/
following documentation apple: https://developer.apple.com/library/ios/documentation/general/conceptual/watchkitprogrammingguide/basicsupport.html#//apple_ref/doc/uid/tp40014969-ch18-sw5
but buttons never show..
my code:
var categories = nsmutableset() var acceptaction = uimutableusernotificationaction() acceptaction.title = nslocalizedstring("accept", comment: "accept") acceptaction.identifier = "accept" acceptaction.activationmode = uiusernotificationactivationmode.background acceptaction.authenticationrequired = false var declineaction = uimutableusernotificationaction() declineaction.title = nslocalizedstring("decline", comment: "decline") declineaction.identifier = "decline" declineaction.activationmode = uiusernotificationactivationmode.background declineaction.authenticationrequired = false var invitecategory = uimutableusernotificationcategory() invitecategory.setactions([acceptaction, declineaction], forcontext: uiusernotificationactioncontext.default) invitecategory.identifier = "cat1" categories.addobject(invitecategory) let settings = uiusernotificationsettings(fortypes: [.alert, .badge, .sound], categories: (nsset(array: [categories])) as? set<uiusernotificationcategory>) uiapplication.sharedapplication().registerusernotificationsettings(settings) uiapplication.sharedapplication().registerforremotenotifications()
my apns code:
$push = new apnsphp_push(apnsphp_abstract::environment_production, 'dict_prod.pem'); $push->setprovidercertificatepassphrase('xxxxxxx'); $push->setrootcertificationauthority('entrust_root_certification_authority.pem'); $push->connect(); $message = new apnsphp_message("the token"); $message->settext("test"); $message->setsound('default'); $message->setexpiry(30); $message->setcategory('cat1'); $push->add($message); $push->send(); $push->disconnect(); $aerrorqueue = $push->geterrors(); if (!empty($aerrorqueue)) { var_dump($aerrorqueue); }
it appears fixed when using:
let categories = nsset(object: invitecategory) let settings = uiusernotificationsettings(fortypes: [.alert, .badge, .sound], categories: categories as! set<uiusernotificationcategory>)
removing:
var categories = nsmutableset()
and
categories.addobject(invitecategory)
Comments
Post a Comment