そのような迅速な返信をしてくれたバディに感謝します私は解決策を見つけました
次のコードであなたはあなたのiPhoneプロファイル(レギュラー/サイレント)をチェックすることができますそしてここにコードがあります
CFStringRef state;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
if(CFStringGetLength(state) == 0) {
//SILENT
NSLog(@"Silent switch is on");
//create vibrate
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
//this 2 line below use to play audio even in silent/vibrator mode too
UInt32 audioCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty( kAudioSessionProperty_AudioCategory, sizeof(UInt32), &audioCategory);
}
else {
//NOT SILENT
NSLog(@"Silent switch is off");
}
そしてこのエラーについて
error: expected identifier before '\x786f7073'
すべてのクラスヘッダーファイルに次の行を書き込むだけです
#import <AudioToolbox/AudioToolbox.h>