美文网首页
iOS Notification Service Extensi

iOS Notification Service Extensi

作者: 花小蓉 | 来源:发表于2021-03-10 16:26 被阅读0次

Appdelegate.m中代码:


NSFileManager *fileManager = [NSFileManager defaultManager];
    NSURL *containerUrl = [fileManager containerURLForSecurityApplicationGroupIdentifier:@"group.com.xxx.share"];
    NSString *newPath = [containerUrl.path stringByAppendingPathComponent:@"Library/Caches"];
    
    NSError *error = nil;
    NSArray *fileList = [[NSArray alloc] init];
    //fileList便是包含有该文件夹下所有文件的文件名及文件夹名的数组
    fileList = [fileManager contentsOfDirectoryAtPath:newPath error:&error];
    NSLog(@"Every Thing in the dir:%@",fileList);
    
    // App写入共享空间
    NSDictionary *dictttt =@{@"launchOptions":@"1"};
    NSString *launchOptionsPath = [newPath stringByAppendingPathComponent:@"launchOptions.plist"];
    [dictttt writeToFile:launchOptionsPath atomically:YES];
    NSLog(@"[WPushLog]:launchOptionsPath :%@", launchOptionsPath);
    
    // 读取Service写入
    NSString *filePathName = [newPath stringByAppendingPathComponent:@"pushFile.plist"];
    NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:filePathName];
    NSLog(@"读取共享空间文件:%@", dict);

NotificationService.m

NSFileManager *fileManager = [NSFileManager defaultManager];
    NSURL *containerUrl = [fileManager containerURLForSecurityApplicationGroupIdentifier:@"group.com.wchat.share"];
    NSString *newPath = [containerUrl.path stringByAppendingPathComponent:@"Library/Caches"];
    
    NSError *error = nil;
    NSArray *fileList = [[NSArray alloc] init];
    //fileList便是包含有该文件夹下所有文件的文件名及文件夹名的数组
    fileList = [fileManager contentsOfDirectoryAtPath:newPath error:&error];
    NSLog(@"Every Thing in the dir:%@",fileList);
    
    // Service写入文件
    NSString *filePathName = [newPath stringByAppendingPathComponent:@"pushFile.plist"];
    [customInfoGDict writeToFile:filePathName atomically:YES];
    NSLog(@"[WPushLog]:filePathName :%@", filePathName);
    
    // 读取App写入文件
    NSString *launchOptions = [newPath stringByAppendingPathComponent:@"launchOptions.plist"];
    NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:launchOptions];
    NSLog(@"[WPushLog]:launchOptions :%@", dict);

相关文章

网友评论

      本文标题:iOS Notification Service Extensi

      本文链接:https://www.haomeiwen.com/subject/aliwqltx.html