add weixinapi

This commit is contained in:
lianxiang
2018-08-27 13:35:39 +08:00
parent a4242fa7b7
commit 6e090fd28d
21 changed files with 325 additions and 58 deletions
+2
View File
@@ -45,6 +45,8 @@
//计算文字的长度
+ (CGSize)sizeWithText:(NSString *)text font:(UIFont *)font maxSize:(CGSize)maxSize;
+(CGFloat)getSpaceLabelHeight:(NSString*)str withFont:(UIFont*)font maxSize:(CGSize)maxSize;
+(void)setLabelSpace:(UILabel*)label withValue:(NSString*)str withFont:(UIFont*)font;
@end
+56 -2
View File
@@ -55,7 +55,6 @@
NSString *futrueTimeStr = [formatter stringFromDate:futrueDate];
NSDate *furtureformatDate = [formatter dateFromString:futrueTimeStr];
long futrueTimestamp= [furtureformatDate timeIntervalSince1970];
return futrueTimestamp;
}
@@ -84,10 +83,65 @@
}
//计算文字的长度
//计算文字size
+ (CGSize)sizeWithText:(NSString *)text font:(UIFont *)font maxSize:(CGSize)maxSize
{
return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:font} context:nil].size;
}
+(CGFloat)getSpaceLabelHeight:(NSString*)str withFont:(UIFont*)font maxSize:(CGSize)maxSize {
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
paraStyle.alignment = NSTextAlignmentLeft;
paraStyle.lineSpacing = 6;
paraStyle.hyphenationFactor = 1.0;
paraStyle.firstLineHeadIndent = 0.0;
paraStyle.paragraphSpacingBefore = 0.0;
paraStyle.headIndent = 0;
paraStyle.tailIndent = 0;
NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@1.5f
};
CGSize size =[str boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
return size.height;
}
+(void)setLabelSpace:(UILabel*)label withValue:(NSString*)str withFont:(UIFont*)font {
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
paraStyle.alignment = NSTextAlignmentLeft;
paraStyle.lineSpacing = 6; //设置行间距
paraStyle.hyphenationFactor = 1.0;
paraStyle.firstLineHeadIndent = 0.0;
paraStyle.paragraphSpacingBefore = 0.0;
paraStyle.headIndent = 0;
paraStyle.tailIndent = 0;
//设置字间距 NSKernAttributeName:@1.5f
NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@1.5f
};
NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:str attributes:dic];
label.attributedText = attributeStr;
}
@end
@@ -28,25 +28,24 @@
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
content.title = alertAction;
content.body = alertBoday;
content.sound = [UNNotificationSound defaultSound];
//content.sound = [UNNotificationSound defaultSound];
content.sound = [UNNotificationSound soundNamed:@"4481.wav"];
//content.sound = UNNotificationSound
//通知附件 音<10M p3 p4 ,视频<50M pmeg mpeg4 图片<5M
NSURL *imageUrl = [[NSBundle mainBundle] URLForResource:@"MaskTime" withExtension:@"png"];
UNNotificationAttachment *attach = [UNNotificationAttachment attachmentWithIdentifier:@"photo" URL:imageUrl options:nil error:nil];
NSURL *audioUrl = [[NSBundle mainBundle] URLForResource:@"pomodoSound" withExtension:@"m4a"];
NSURL *audioUrl = [[NSBundle mainBundle] URLForResource:@"4481" withExtension:@"wav"];
UNNotificationAttachment *attachAudio = [UNNotificationAttachment attachmentWithIdentifier:@"audio" URL:audioUrl options:nil error:nil];
NSURL *vedioUrl = [[NSBundle mainBundle] URLForResource:@"emojizone" withExtension:@"mp4"];
UNNotificationAttachment *vedioAudio = [UNNotificationAttachment attachmentWithIdentifier:@"vedio" URL:vedioUrl options:nil error:nil];
content.attachments = @[vedioAudio];
content.attachments = @[attachAudio];
//延迟通知 第一个参数是重复的时间间隔,最小60s,第二个参数是是否重复。
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:timeInterval repeats:NO];
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:60 repeats:NO];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
[center addNotificationRequest:request withCompletionHandler:^(NSError *_Nullable error) {
GILog(@"成功添加推送");
@@ -62,6 +61,7 @@
localNotification.alertAction = alertAction;
localNotification.applicationIconBadgeNumber = 1;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.soundName = @"4481.wav";
//localNotification.alertLaunchImage = @"MaskTime.png";
localNotification.userInfo = @{identifier:identifier};
//根据设定时间发送通知
@@ -127,6 +127,7 @@ API_AVAILABLE(ios(10.0)){
NSLog(@"iOS10 前台 收到本地通知:{\\\\nbody:%@\\\\ntitle:%@,\\\\nsubtitle:%@,\\\\nbadge%@\\\\nsound%@\\\\nuserInfo%@\\\\n}",body,title,subtitle,badge,sound,userInfo);
[self showAlert:title message:body];
[center removeAllPendingNotificationRequests];
}
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
}
@@ -136,7 +137,7 @@ API_AVAILABLE(ios(10.0)){
API_AVAILABLE(ios(10.0)){
GILog(@"ios10用户点击通知栏相应");
[center removeAllPendingNotificationRequests];
completionHandler();
}
//
+2
View File
@@ -12,4 +12,6 @@
+(GiGaNetManager *)shareInstance;
+(void)request:(GiGaAPIRequest*)api;
@end
+2
View File
@@ -67,4 +67,6 @@
}
}
@end
@@ -0,0 +1,35 @@
//
// WeiIXinApiManager.h
// GIGA
//
// Created by lianxiang on 2018/8/27.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WeiIXinApiManager : NSObject
/**
access_token
@param url get access_token
@param parameters
@param success
@param failure
*/
+(void)weixinAccessTokeRequstUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id response))success
failure:(void (^)(NSError *err))failure;
/**
@param parameters
@param success
@param failure
*/
+(void)getWeiXinUserInfoUrl:(NSString *)url parameters:(NSDictionary *)parameters
success:(void (^)(id response))success
failure:(void (^)(NSError *err))failure;
@end
@@ -0,0 +1,45 @@
//
// WeiIXinApiManager.m
// GIGA
//
// Created by lianxiang on 2018/8/27.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "WeiIXinApiManager.h"
@implementation WeiIXinApiManager
+(void)weixinAccessTokeRequstUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id response))success
failure:(void (^)(NSError *err))failure
{
[self getrequstweiAPiUrl:url params:parameters success:success failure:failure];
}
+ (void)getWeiXinUserInfoUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id))success failure:(void (^)(NSError *))failure
{
[self getrequstweiAPiUrl:url params:parameters success:success failure:failure];
}
+(void)getrequstweiAPiUrl:(NSString *)url params:(NSDictionary *)parameters success:(void (^)(id response))success
failure:(void (^)(NSError *err))failure
{
AFHTTPSessionManager*manager=[[AFHTTPSessionManager alloc] init];
manager.responseSerializer=[AFHTTPResponseSerializer serializer];
[manager GET:url parameters:parameters progress:^(NSProgress * _Nonnull downloadProgress) {
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
if (success) {
success(responseObject);
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
if (failure) {
failure(error);
}
}];
}
@end
+8
View File
@@ -39,5 +39,13 @@
+(void)saveAppGaurdflag:(BOOL)showedGaurd;
+(BOOL)isShowedAppGaurd;
/**
access_token返回信息
@param dic
*/
+(void)saveWeiXinaccesstokenInfoWithDic:(NSDictionary *)dic;
+(NSDictionary *)getWeiXinAccessToenDic;
@end
+11
View File
@@ -12,6 +12,7 @@ NSString *const kUserManagerVerision = @"GiGAUserDBVeriosn";
NSString *const GIGADEFAULTKEY_USERID = @"GiGaUserId";
NSString *const kShowUserGuard = @"ShowUserGuard";
NSString *const kShowAppGuard = @"ShowAppGuard";
NSString *const kWeiXinSaveToken = @"WeiXinSaveToken";
@implementation GiGaUserDefault
@@ -77,4 +78,14 @@ NSString *const kShowAppGuard = @"ShowAppGuard";
return showedGaurd;
}
+(void)saveWeiXinaccesstokenInfoWithDic:(NSDictionary *)dic
{
[UD_STADARDUD setObject:dic forKey:kWeiXinSaveToken];
}
+(NSDictionary *)getWeiXinAccessToenDic{
return [UD_STADARDUD objectForKey:kWeiXinSaveToken];
}
@end
Binary file not shown.