sgcWebSockets 라이브러리는 서버와 클라이언트 측 컴포넌트 모두에서 HTTP/2 프로토콜을 지원해요. Apple Push 알림은 HTTP/2 프로토콜을 사용하는 서버 제공자에서만 Push 알림을 보낼 수 있게 허용해요. 다음 글들에서는l show how send push notifications using sgcWebSockets library.
The Server Provider (who sends the push notifications to user's devices) requires to know which is the device token where the messages will be delivered. A Device Token is an unique identifier associated to a device and application.
Using Rad Studio, you can get the device token id using the unit FMX.PushNotification.iOS. The concept is quite simple, the device opens a new connection to the apple servers and gets a DeviceToken which will be used by Server provider to send notifications. Find below a sample code for Delphi where you can get the Device Token.
Delphi 코드
oPushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.APS);
oPushConnection := TPushServiceConnection.Create(oPushService);
oPushConnection.Active := True;
oPushConnection.OnChange := OnChangeEvent;
oPushConnection.OnReceiveNotification := OnReceiveNotificationEvent;
vDeviceId := oPushService.DeviceIDValue[TPushService.TDeviceIDNames.DeviceID];
vDeviceToken := oPushService.DeviceTokenValue[TPushService.TDeviceTokenNames.DeviceToken];
procedure OnChangeEvent(Sender: TObject; AChange: TPushService.TChanges);
begin
memoLog.Lines.Add('OnChange');
end;
procedure OnReceiveNotificationEvent(Sender: TObject; const ANotification: TPushServiceNotification);
begin
memoLog.Lines.Add('DataKey=' + ANotification.DataKey);
memoLog.Lines.Add('JSON=' + ANotification.JSON.ToString);
memoLog.Lines.Add('DataObject=' + ANotification.DataObject.ToString);
end;
