-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDW.RemoteNotificationsPatch.iOS.pas
60 lines (46 loc) · 1.46 KB
/
DW.RemoteNotificationsPatch.iOS.pas
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
unit DW.RemoteNotificationsPatch.iOS;
interface
implementation
{$IF Defined(IOS)}
uses
System.SysUtils, iOSapi.Foundation, DW.iOSapi.UserNotifications;
type
TRemoteNotificationsPatch = class(TObject)
private
class var FCurrent: TRemoteNotificationsPatch;
class destructor DestroyClass;
private
procedure RequestAuthorizationWithOptionsCompletionHandler(granted: Boolean; error: NSError);
procedure InternalRequestAuthorization;
protected
class procedure RequestAuthorization;
end;
{ TRemoteNotificationsPatch }
class destructor TRemoteNotificationsPatch.DestroyClass;
begin
FCurrent.Free;
end;
procedure TRemoteNotificationsPatch.InternalRequestAuthorization;
var
LOptions: UNAuthorizationOptions;
begin
LOptions := UNAuthorizationOptionSound or UNAuthorizationOptionAlert or UNAuthorizationOptionBadge;
UserNotificationCenter.requestAuthorizationWithOptions(LOptions, RequestAuthorizationWithOptionsCompletionHandler);
end;
procedure TRemoteNotificationsPatch.RequestAuthorizationWithOptionsCompletionHandler(granted: Boolean; error: NSError);
begin
//
end;
class procedure TRemoteNotificationsPatch.RequestAuthorization;
begin
if TOSVersion.Check(10) then
begin
if FCurrent = nil then
FCurrent := TRemoteNotificationsPatch.Create;
FCurrent.InternalRequestAuthorization;
end;
end;
initialization
TRemoteNotificationsPatch.RequestAuthorization;
{$ENDIF}
end.