Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 通知起作用,但没有声音_Ios_Notifications - Fatal编程技术网

Ios 通知起作用,但没有声音

Ios 通知起作用,但没有声音,ios,notifications,Ios,Notifications,我正在尝试将此代码置于AppDelegate.m下以测试本地通知: - (void)applicationDidEnterBackground:(UIApplication *)application { NSDate *alertTime = [[NSDate date]dateByAddingTimeInterval:5]; UIApplication* thisApp = [UIApplication sharedApplication]; UILocalN

我正在尝试将此代码置于AppDelegate.m下以测试本地通知:

- (void)applicationDidEnterBackground:(UIApplication *)application
{    
    NSDate *alertTime = [[NSDate date]dateByAddingTimeInterval:5];
    UIApplication* thisApp = [UIApplication sharedApplication];
    UILocalNotification* notify = [[UILocalNotification alloc] init];
    if (notify){
        notify.fireDate = alertTime;
        notify.timeZone = [NSTimeZone defaultTimeZone];
        notify.repeatInterval = 0;
        notify.alertBody = @"This is notification";
        [thisApp scheduleLocalNotification:notify];
    }
}
但我听不到任何声音,就像其他应用程序一样。我们应该提供自己的声音吗?我们不能在通知中使用Apple native sound吗

以及如何设置通知的“标题文本”?因为我看到的只是
notify.alertBody=@“这是通知”在标题上不生成任何内容,但将“通知”作为标题


谢谢……

声音

您需要通过指定自己的声音文件名或默认名称来指定您想要的声音:

对于此属性,指定应用程序主捆绑包中声音资源的文件名(包括扩展名)或UILocalNotificationDefaultSoundName以请求默认系统声音。当系统显示本地通知警报或标记应用程序图标时,会播放此声音。默认值为零(无声音)。不支持持续时间超过30秒的声音。如果指定的文件的声音播放时间超过30秒,将改为播放默认声音

标题


您不能修改通知的标题。它将始终是您的应用程序名称,以便用户准确知道通知来自何处。

声音

您需要通过指定自己的声音文件名或默认名称来指定您想要的声音:

对于此属性,指定应用程序主捆绑包中声音资源的文件名(包括扩展名)或UILocalNotificationDefaultSoundName以请求默认系统声音。当系统显示本地通知警报或标记应用程序图标时,会播放此声音。默认值为零(无声音)。不支持持续时间超过30秒的声音。如果指定的文件的声音播放时间超过30秒,将改为播放默认声音

标题

您不能修改通知的标题。它将始终是您的应用程序名称,以便用户确切知道通知来自何处