函数“AudioServicesPlaySystemSoundWithVibration”的隐式声明在 c99 中无效

Posted

技术标签:

【中文标题】函数“AudioServicesPlaySystemSoundWithVibration”的隐式声明在 c99 中无效【英文标题】:Implicit declaration of function 'AudioServicesPlaySystemSoundWithVibration' is invalid in c99 【发布时间】:2015-03-31 11:25:04 【问题描述】:

我需要 500 毫秒的振动,因为我正在使用下面的代码

NSMutableDictionary* dict = [NSMutableDictionary dictionary];
NSMutableArray* arr = [NSMutableArray array ];

[arr addObject:[NSNumber numberWithBool:YES]];    //stop for 500ms
[arr addObject:[NSNumber numberWithInt:500]];

[dict setObject:arr forKey:@"VibePattern"];
[dict setObject:[NSNumber numberWithInt:1] forKey:@"Intensity"];


 AudioservicesPlaySystemSoundWithVibration(4095,nil,dict);

AudioServicesPlaySystemSoundWithVibration 运行良好,但发出警告以及我无法将我的应用程序发布到应用商店。

我会在我的项目中包含 AudioTools 框架

请帮帮我

提前致谢

【问题讨论】:

这是一个私有的API方法,你不能使用它。改为查看***.com/questions/4724980/making-the-iphone-vibrate 谢谢 luk2302 AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); 这两个功能振动手机,但我需要 500 毫秒的振动,这种方法给我超过 500 毫秒。我只需要一点振动。 我认为隐藏私有 c API 是不可能的。 【参考方案1】:

尝试使用FOUNDATION_EXTERN宏声明函数:

FOUNDATION_EXTERN AudioServicesPlaySystemSoundWithVibration(unsigned long, objc_object*, NSDictionary*)

但要做好因使用私有 API 而被拒绝的准备,尤其是在美国 App Store 上。

【讨论】:

以上是关于函数“AudioServicesPlaySystemSoundWithVibration”的隐式声明在 c99 中无效的主要内容,如果未能解决你的问题,请参考以下文章