aboutsummaryrefslogtreecommitdiffstats
path: root/CopyMailto/DefaultURLHandler.m
blob: 8ce1728e99d2cd54f7502965d2909973d68b04f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
//  DefaultURLHandler.m
//  CopyMailto
//
//  Created by tw on 9/5/18.
//  Copyright © 2018 tw. All rights reserved.
//

#import "DefaultURLHandler.h"

@implementation DefaultURLHandler

+ (OSStatus)setDefaultURLHandler {
    CFStringRef scheme = (CFStringRef)@"mailto";
    CFStringRef bundle_identifier = (__bridge CFStringRef)[[NSBundle mainBundle] bundleIdentifier];
    NSLog(@"%@", bundle_identifier);

    OSStatus status = LSSetDefaultHandlerForURLScheme(scheme, bundle_identifier);
    NSLog(@"%d", status);

    CFRelease(scheme);

    return status;
}

+ (void)saveDefaultURLHandler {
    CFStringRef mailto = (CFStringRef)@"mailto";
    CFStringRef bundle_identifier = LSCopyDefaultHandlerForURLScheme(mailto);
    NSLog(@"%@", bundle_identifier);

    CFRelease(mailto);
    CFRelease(bundle_identifier);
}

@end