Skip to content

Commit

Permalink
Tring to fix push issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Evsio0n committed Feb 10, 2020
1 parent cfd8cbc commit d25a33d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions ios/Runner/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,25 @@ - (void)application:(UIApplication *)application didRegisterForRemoteNotificatio
NSDateFormatter *forMatter = [[NSDateFormatter alloc] init];
[forMatter setDateFormat:@"yyyy/MM/dd HH:mm:ss"];
SendTime = [forMatter stringFromDate:now]; // 转换系统现在的时间
NSString *tokenString = [[NSString alloc] initWithData:deviceToken encoding:NSSymbolStringEncoding];
token = tokenString;
if(@available(iOS 13.0,*)){
if(deviceToken.length !=0 ){
NSUInteger capacity = deviceToken.length * 2;
NSMutableString *ptoken = [NSMutableString stringWithCapacity:capacity];
const unsigned char *buf = (const unsigned char*) [deviceToken bytes];
NSInteger t;
for (t=0; t<deviceToken.length; ++t) {
[ptoken appendFormat:@"%02lX", (unsigned long)buf[t]];
}
token = [[ptoken description] stringByReplacingOccurrencesOfString:@"-" withString:@""];
}
}
else {
token = [[[[deviceToken description]
stringByReplacingOccurrencesOfString:@" " withString:@""]
stringByReplacingOccurrencesOfString:@"<" withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""];
}
NSLog(@">>>>[Token]:%@<<<<<<<<",token);
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
Expand Down

0 comments on commit d25a33d

Please sign in to comment.