ios - Badgeicon and sound is not dispalying when notification fires in ios8 on real device -
i'm using localnotification ios 8,badge icon , sound not working fine me in real device.here code
in appdelegate.m
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // override point customization after application launch. if ([uiapplication instancesrespondtoselector:@selector(registerusernotificationsettings:)]) { [application registerusernotificationsettings:[uiusernotificationsettings settingsfortypes:uiusernotificationtypealert|uiusernotificationtypebadge|uiusernotificationtypesound categories:nil]]; } [self.window makekeyandvisible]; homecoming yes; }
in viewcontroller.m
uilocalnotification *localnotification = [[uilocalnotification alloc] init]; localnotification.firedate = [nsdate datewithtimeintervalsincenow:10]; localnotification.alertbody = @"time up!"; localnotification.soundname = uilocalnotificationdefaultsoundname; localnotification.timezone=[nstimezone defaulttimezone]; [[uiapplication sharedapplication] schedulelocalnotification:localnotification]; localnotification.applicationiconbadgenumber=1;
you have set badge before schedule notification
localnotification.applicationiconbadgenumber=1; [[uiapplication sharedapplication] schedulelocalnotification:localnotification];
for sound code correct. check device sound. settings > sounds.
ios objective-c notifications
No comments:
Post a Comment