收到推送後,播放聲音:
首先添加頭文件
#import <AudioToolbox/AudioToolbox.h>
<一> 自定義音效
//音效文件路徑
NSString *path = [[NSBundlemainBundle] pathForResource:@"new_order"ofType:@"wav"];
//組裝並播放音效
SystemSoundID soundID;
NSURL *filePath = [NSURLfileURLWithPath:path isDirectory:NO];
AudioServicesCreateSystemSoundID((__bridgeCFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);
//聲音停止
AudioServicesDisposeSystemSoundID(soundID);
<二> 系統音效
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);