在C99中,隐式声明函数'AudioServicesPlaySystemSoundWithVibration'是无效的。

4

我需要500ms的震动,为此我正在使用以下代码:

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方法,你不被允许使用它。请看https://dev59.com/X2445IYBdhLWcg3wucmo。 - luk2302
谢谢luk2302AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);这两个函数可以使手机震动,但我需要500ms的震动,而这种方法给我的震动时间超过了500ms。我只需要一点点的震动。 - Bhavsar1311
我认为隐藏私有的C API是不可能的。 - kelin
1个回答

1
尝试使用FOUNDATION_EXTERN宏声明函数:
FOUNDATION_EXTERN AudioServicesPlaySystemSoundWithVibration(unsigned long, objc_object*, NSDictionary*)

但是要做好因为使用私有API而被拒绝的准备,特别是在美国的应用商店。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接