我建立一个具有短信作曲家(这是不提供3.0)的应用程序。 如何动态查找底层设备的操作系统版本并使SMS选项可用,并且如果不禁用该功能。
回答
参考,我认为你可以使用NSClassFromString(@"MFMessageComposeViewController")
,看是否类是可用的。
(警告:。你不能检查UIGestureRecognizer
这种方式,因为苹果使用的专用类使用相同名称能为MFMessageComposeViewController
是真实的)
这是我上面评论的内容 - 切换功能 - 不是偶然的相关数据。 – bryanmac
谢谢brynmac&Barum –
UIDevice类具有可用于获取操作系统版本的systemVersion属性。这将返回版本值,如3.1或4.2。猜猜你可以使用它来确定对你的短信功能的访问。
@property (nonatomic, readonly, retain) NSString *systemVersion
谢谢machan –
下面是一段代码,这将给你所有的关于设备的信息
NSLog(@"uniqueIdentifier: %@", [[UIDevice currentDevice] uniqueIdentifier]);
NSLog(@"name: %@", [[UIDevice currentDevice] name]);
NSLog(@"systemName: %@", [[UIDevice currentDevice] systemName]);
NSLog(@"systemVersion: %@", [[UIDevice currentDevice] systemVersion]);
NSLog(@"model: %@", [[UIDevice currentDevice] model]);
NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel]);
你可以在这里获得版本号。
但我会建议你去与检查该手机支持邮件撰写,短信或不喜欢
类MessageClass的=(NSClassFromString(@“MFMessageComposeViewController”));
if (messageClass != nil) {
// Check whether the current device is configured for sending SMS messages
if ([messageClass canSendText])
{
MFMessageComposeViewController *msgpicker = [[MFMessageComposeViewController alloc] init];
msgpicker.messageComposeDelegate = self;
msgpicker.recipients = [NSArray arrayWithObject:[self.productInfoArray valueForKey:@"Phone"]]; // your recipient number or self for testing
msgpicker.body = @"test from OS4";
NSLog(@"chat view array %@",[self.productInfoArray valueForKey:@"Phone"]);
[self presentModalViewController:msgpicker animated:YES];
[msgpicker release];
NSLog(@"SMS fired");
}
else { NSLog(@"chat view array %@",[self.productInfoArray valueForKey:@"Phone"]);
NSLog(@"Device not configured to send SMS.") ;
UIAlertView *alert= [[UIAlertView alloc]initWithTitle:@"Status" message:@"Device not configured to send SMS." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"cancel",nil];
[alert show];
[alert release];
}
}
这将有助于解决您的问题。 快乐编码 Cheers ................
谢谢Sabby –
欢迎你亲爱的......干杯 – Sabby
- 1. 识别iPad的设备iOS 4.2
- 2. 使用Nmap的移动设备识别
- 3. 支持旧的iOS版本和设备
- 4. Windows设备不再识别Android设备
- 5. 唯一识别移动设备
- 6. 移动设备上的本地口头命令识别
- 7. 唯一识别设备
- 8. 语音识别USB设备
- 9. Android识别独特设备
- 10. 如何识别不同iOS设备上的同一用户
- 11. RegexKitLite - iOS设备:无法识别的选择
- 12. 识别iOS SDK中的每个iphone设备
- 13. java版本无法识别
- 14. 识别.Net框架版本
- 15. USB设备版本
- 16. Android设备版本
- 17. Twilio设备版本
- 18. addSubview - iOS设备8 VS iOS版9
- 19. ZBar iOS自动识别
- 20. ios的唯一设备标识
- 21. iOS智能应用横幅无法识别设备/兼容性
- 22. 我可以识别当前iOS设备是否用于开发?
- 23. iOS 8设备未被iPhone配置实用程序识别
- 24. 如何在iOS设备上识别用户?
- 25. 如何识别iOS设备(而不是imei)
- 26. 如何从应用中识别企业(企业)iOS设备?
- 27. 识别不支持的设备
- 28. Android无法识别我的设备
- 29. 没有识别的Bacnet设备pointname
- 30. Eclipse无法识别我的Android设备
通过将它与恰好在其中启用的版本相关联来确定服务可用性总是有点脆弱。未来,如果该服务可用时有任何差异,代码将开始打破。我对SMS编写器知之甚少,但是如果有一种编程方式来确定服务是否可用,那么它将比它发生的版本检查更好。 – bryanmac