知止安能定,定而知静,静方可虑,虑而后能得。---iOS交流群67784110
1 |
|
Apple Pay,是苹果公司在2014年苹果秋季新品发布会上发布的一种基于NFC(近场通讯)的手机支付功能,2016年2月18日凌晨5点,Apple Pay业务在中国上线。
它的支付方式是通过Touch ID/Passcode
验证方式,用户可使用事先已经储存在IPhone 6 ,6p或者更新设备上的银行卡支付证书来授权支付,当然最新的5e,同样支持Apple Pay支付。
也就是说你的苹果设备要在IOS8.0及以上版本,并在wallet应用中,添加银行卡信息,从而使用Apple Pay。
它所支持的银行可以到官方查看,这里给出官方链接
手机怎么添加银行卡,这里不过多介绍,只需要按照手机提示即可。
//判断是否在中国
if(![LocationConverter isLocationOutOfChinaRay:[LocationConverter transformFromGCJToWGS:customLoc2D]])
{
NSLog(@”%@”,reGeocode.formattedAddress);
//查询逆地理编码成功
[ws.headMap setLocationInfo:reGeocode];
//模糊查询本地城市列表
CityInfo *searchInfo = [[CityInfo alloc]init];
if ([CommonHelp isBlankString:reGeocode.addressComponent.city] )
{
//城市名模糊查询
searchInfo.cityName = [NSString stringWithFormat:@”%@”,[reGeocode.addressComponent.province stringByReplacingOccurrencesOfString:@”市” withString:@””]];
}else
{
//城市名模糊查询
searchInfo.cityName = [NSString stringWithFormat:@”%@”,[reGeocode.addressComponent.city stringByReplacingOccurrencesOfString:@”市” withString:@””]];
}
DatabaseManager *manager = [DatabaseManager sharedInstance];
NSArray *cityArr = [manager queryCityWithInfo:searchInfo];
CityInfo *resultInfo;
if(cityArr.count >0)
{
resultInfo = cityArr[0];
}
[USDF setObject:resultInfo.adCode forKey:@"adCode"];
[USDF setObject:reGeocode.formattedAddress forKey:@"currentPosition"];
[USDF setObject:reGeocode.addressComponent.citycode forKey:@"citycode"];
[USDF setObject:[NSString stringWithFormat:@"%f",location.coordinate.latitude] forKey:@"latitude"];
[USDF setObject:[NSString stringWithFormat:@"%f",location.coordinate.longitude] forKey:@"longitude"];
[ws requestListData];//获取数据
}else
{
NSString * latlon= [NSString stringWithFormat:@"&lat=%f&lon=%f",location.coordinate.latitude,location.coordinate.longitude];
AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
session.responseSerializer = [AFHTTPResponseSerializer serializer];
//网络请求时间
[session.requestSerializer willChangeValueForKey:@"timeoutInterval"];
session.requestSerializer.timeoutInterval = 10;
[session.requestSerializer didChangeValueForKey:@"timeoutInterval"];
[session POST:[NSString stringWithFormat:@"http://nominatim.openstreetmap.org/reverse?zoom=10&addressdetails=1&format=json%@",latlon] parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
id result=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
NSLog(@"请求成功数据-->%@",result);
NSDictionary * dic = [[NSDictionary alloc] initWithDictionary:[result objectForKey:@"address"]];
NSString * address = [dic objectForKey:@"city"];
NSString * displayName = [NSString stringWithFormat:@"%@",[result objectForKey:@"display_name"]];
[ws.headMap setLocationtext:displayName];
//模糊查询本地城市列表
CityInfo *searchInfo = [[CityInfo alloc]init];
NSString * a = [NSString stringWithFormat:@"%@",[address stringByReplacingOccurrencesOfString:@"特别" withString:@""]];
NSString * locatedAt = [NSString stringWithFormat:@"%@",[a stringByReplacingOccurrencesOfString:@"市" withString:@""]];
//城市名模糊查询
searchInfo.cityName = locatedAt;
DatabaseManager *manager = [DatabaseManager sharedInstance];
NSArray *cityArr = [manager queryCityWithInfo:searchInfo];
CityInfo *resultInfo;
if(cityArr.count >0)
{
resultInfo = cityArr[0];
}
[USDF setObject:resultInfo.adCode forKey:@"adCode"];
[USDF setObject:displayName forKey:@"currentPosition"];
[USDF setObject:resultInfo.adCode forKey:@"citycode"];
[USDF setObject:[NSString stringWithFormat:@"%f",location.coordinate.latitude] forKey:@"latitude"];
[USDF setObject:[NSString stringWithFormat:@"%f",location.coordinate.longitude] forKey:@"longitude"];
[ws requestListData];//获取数据
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//NSLog(@"%@",error);
}];
// [self.geocoder reverseGeocodeLocation: location completionHandler:
// ^(NSArray placemarks, NSError error) {
// if (error == nil) {
// // 系统反地理编码成功
// //得到自己当前最近的地名
// CLPlacemark placemark = [placemarks objectAtIndex:0];
// NSDictionary dic = placemark.addressDictionary;
// NSString locatedAt = placemark.locality;
// NSString ads=[NSString stringWithFormat:@”%@,%@”,placemark.name,placemark.locality];
// [ws.headMap setLocationtext:ads];
//
// //模糊查询本地城市列表
// CityInfo searchInfo = [[CityInfo alloc]init];
// //城市名模糊查询
// searchInfo.cityName = [NSString stringWithFormat:@”%@”,[locatedAt stringByReplacingOccurrencesOfString:@”市” withString:@””]];
// DatabaseManager manager = [DatabaseManager sharedInstance];
// NSArray cityArr = [manager queryCityWithInfo:searchInfo];
// CityInfo resultInfo;
// if(cityArr.count >0)
// {
// resultInfo = cityArr[0];
// }
// if(resultInfo.adCode == nil)
// {
// [USDF setObject:@”110000” forKey:@”adCode”];
// }else
// {
// [USDF setObject:resultInfo.adCode forKey:@”adCode”];
// }
//
// [USDF setObject:ads forKey:@”currentPosition”];
// [USDF setObject:placemark.postalCode forKey:@”citycode”];
// [USDF setObject:[NSString stringWithFormat:@”%f”,location.coordinate.latitude] forKey:@”latitude”];
// [USDF setObject:[NSString stringWithFormat:@”%f”,location.coordinate.longitude] forKey:@”longitude”];
//
// [ws requestListData];//获取数据
//
// } else {
// // 系统自带反地理编码失败,由 Google 接管。
// NSLog(@”123”);
// }
// }];
}
本文是根据DeveloperLx在斗鱼直播ReactiveCocoa
时整理的文章,同时加上本人的见解,若有错误希望指出。
感谢 DeveloperLx 为大家做出的贡献,虽然直播声音小了点,但满满的都是干货 ^v^
这篇文章主要针对,上篇的iOS开发之内购-AppStore中,In App Purchase的问题和解决办法。
实质上oc与js的通信交互就是发送消息,也即函数调用,iOS7以后官方公布JavaScriptCore framework中很方便我们对他们之间的相互调用。在以前我们只能通过UIWebView的UIWebViewDelegate协议来实现.
1 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType; |
或者
1 | - (void)webViewDidStartLoad:(UIWebView *)webView; |