- (void)messageButtonEvent{
// 短信號碼可以爲空
NSString *phone = [NSString stringWithFormat:@"10086"];// 發短信的號碼
NSString *content = @"祝願你新春歡樂!閤家歡樂!萬事如意!百事順心!幸福美滿!吉星高照!花開富貴!迎福納祥!四季發財!";
NSString *urlStr = [NSString stringWithFormat:@"sms://%@&body=%@", phone, content];
// 對中文進行編碼 不進行中文編碼,可能到時短信內容爲null
urlStr = [urlStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSURL *url = [NSURL URLWithString:urlStr];
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
} else {
[[UIApplication sharedApplication] openURL:url];
}
}