识别设备的IOS版本动态
我建立一个具有短信作曲家(这是不提供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
通过将它与恰好在其中启用的版本相关联来确定服务可用性总是有点脆弱。未来,如果该服务可用时有任何差异,代码将开始打破。我对SMS编写器知之甚少,但是如果有一种编程方式来确定服务是否可用,那么它将比它发生的版本检查更好。 – bryanmac