可能重复:
检查iPhone iOS版本
我正在构建一个具有SMS编写器的应用程序(在3.0中不可用).如何动态查找底层设备的操作系统版本并使SMS选项可用,如果不能禁用该功能.
这是一段代码,它将为您提供有关设备的所有信息
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]);
Run Code Online (Sandbox Code Playgroud)
你可以在这里找到版本号.
但我建议你去检查手机是否支持邮件编辑,短信或不喜欢
class 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];
}
}
Run Code Online (Sandbox Code Playgroud)
这有助于解决您的问题.快乐的编码干杯................
| 归档时间: |
|
| 查看次数: |
1101 次 |
| 最近记录: |