ios - Detecting push notification event in cordova app after cold start (from notification click) -
my push notifications contain custom data helps route app right place when notification clicked. these work fine if app open or in background, don't work when app closed. notification opens app code doesn't detect referenced notification event can route it. have in appdelegate.m
#ifndef disable_push_notifications - (void) application:(uiapplication*)application didregisterforremotenotificationswithdevicetoken:(nsdata*)devicetoken { // re-post ( broadcast ) nsstring* token = [[[[devicetoken description] stringbyreplacingoccurrencesofstring:@"<" withstring:@""] stringbyreplacingoccurrencesofstring:@">" withstring:@""] stringbyreplacingoccurrencesofstring:@" " withstring:@""]; [[nsnotificationcenter defaultcenter] postnotificationname:cdvremotenotification object:token]; } - (void) application:(uiapplication*)application didfailtoregisterforremotenotificationswitherror:(nserror*)error { // re-post ( broadcast ) [[nsnotificationcenter defaultcenter] postnotificationname:cdvremotenotificationerror object:error]; } #endif i have js code in place catch notification in app
document.addeventlistener('push-notification', function(event) { //get notification payload console.log("incoming push notification!") console.log(event); factory.reacttoincomingpushnotification(event) }); my question how reference notification event in app once app has cold started?
i have cordova/ionic app pushwoosh provider. testing on ios.
if app terminated, , user want custom data on tap of notification, didfinishlaunchingwithoptions of appdelegate method contains data in key called uiapplicationlaunchoptionsremotenotificationkey
Comments
Post a Comment