Local notification in iOS coming without any sound

这一生的挚爱 提交于 2019-12-24 00:39:02

问题


-(void)notifyMe
{
    UILocalNotification *localNotification = [[UILocalNotification alloc] init];
    localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:0.1];
    localNotification.timeZone = [NSTimeZone defaultTimeZone];
    localNotification.alertBody = @"Alert";
    localNotification.alertAction = @"Local notification";
    localNotification.soundName = UILocalNotificationDefaultSoundName;
    localNotification.alertLaunchImage = nil;
    localNotification.userInfo = nil;
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}

This is the method I am calling for local notification. This is working fine with other applications. But with my working one, notification is coming but with no sound.

I guess there is some problem with app setting, but I am unable to find it out.


回答1:


I found your question as I had run into the same problem. Turns out it was a simple fix on my part, my code was fine all I had to do was enable push notifications for my app (which I had already done but was getting no sound or badge), and then switch Badge App Icon and Sound to ON.

I'm surprised there have been no other answers to this question in 6 months.



来源:https://stackoverflow.com/questions/19219140/local-notification-in-ios-coming-without-any-sound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!