objective c - iOS Notifications: callbacks not called -
i'm implenting reminder feature app through local notifications. user setup times , repetition intervals , app schedule respective notifications this:
uilocalnotification *notification = ...; [[uiapplication sharedapplication] schedulelocalnotification:notification];
for work need register notification types this:
uiusernotificationsettings *notificationsettings; notificationsettings = [uiusernotificationsettings settingsfortypes:uiusernotificationtypealert categories:nil]; [[uiapplication sharedapplication] registerusernotificationsettings:notificationsettings];
although notifications scheduled correctly none of appdelegate callbacks (didregisterusernotificationsettings
, didreceivelocalnotification
) called. need react notifications when app in foreground.
registering notification settings should trigger callback message in appdelegate:
- (void)application:(uiapplication *)application didregisterusernotificationsettings:(uiusernotificationsettings *)notificationsettings { nslog(@"callback called."); }
it works fine quick test project (new project -> single view app -> add register code , callback -> launch). callback gets called.
however, in real app not work.
i completly stripped apps appdelegate (removed custom init code, no ui loading) registers notification settings. fresh app install triggers user confirmation dialog correctly. callbacks won't called.
am missing build setting/compiler flag? i'm not aware of special settings app pointing in direction. can't spot difference example project.
xcode 7.2 , ipod5 ios9.2.1
ouch. makes perfect reason facepalm...
in order detect ui events within whole app, appdelegate changed exdend uiapplication
use - (void)sendevent:(uievent *)event
callback. appdelegate should extend uiresponder
.
you can setup different classes both uses in main.m
:
int main(int argc, char *argv[]) { @autoreleasepool { @try { // original appdelegate extending uiresponder nsstring *maindelegate = nsstringfromclass([appdelegate class]); // new class extending uiapplication nsstring *mainclass = nsstringfromclass([appmain class]); return uiapplicationmain(argc, argv, mainclass, maindelegate); } @catch (nsexception *exception) { nslog(@"%@", [exception reason]); } } }
i thank suggestions. have take step back.
Comments
Post a Comment