Перейти к содержанию

Denisviz

Пользователи
  • Активность

    1
  • Зарегистрирован

  • Посещение

Информация о Denisviz

  • Звание
    Новичок
  1. Здравствуйте, хочу настроить Push уведомления на андроиде, делал по примеру с документации http://docwiki.embarcadero.com/RADStudio/Rio/en/Firebase_Android_Support При запуске программы выдает ошибку "external exception 36" или "external exception D6". Подскажите пожалуйста, может где-то нужно расширить дозвала. Заранее спасибо unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.PushNotification.Android, FMX.Memo.Types, FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, System.PushNotification, JSON, FMX.StdCtrls, FMX.Helpers.Android, FMX.Objects,FMX.Platform; type TForm1 = class(TForm) MemoLog: TMemo; Button1: TButton; procedure OnReceiveNotificationEvent(Sender: TObject; const ServiceNotification: TPushServiceNotification); procedure OnServiceConnectionChange(Sender: TObject; PushChanges: TPushService.TChanges); procedure Button1Click(Sender: TObject); private FDeviceId: string; FDeviceToken: string; { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} procedure TForm1.Button1Click(Sender: TObject); var PushService: TPushService; ServiceConnection: TPushServiceConnection; Notifications: TArray<TPushServiceNotification>; begin PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM); ServiceConnection := TPushServiceConnection.Create(PushService); ServiceConnection.Active := True; ServiceConnection.OnChange := OnServiceConnectionChange; ServiceConnection.OnReceiveNotification := OnReceiveNotificationEvent; FDeviceId := PushService.DeviceIDValue[TPushService.TDeviceIDNames.DeviceId]; MemoLog.Lines.Add('DeviceID: ' + FDeviceId); MemoLog.Lines.Add('Ready to receive!'); // Checks notification on startup, if application was launched fromcold start // by tapping on Notification in Notification Center Notifications := PushService.StartupNotifications; if Length(Notifications) > 0 then begin MemoLog.Lines.Add('-----------------------------------------'); MemoLog.Lines.Add('DataKey = ' + Notifications[0].DataKey); MemoLog.Lines.Add('Json = ' + Notifications[0].Json.ToString); MemoLog.Lines.Add('DataObject = ' + Notifications[0].DataObject.ToString); MemoLog.Lines.Add('-----------------------------------------'); end; end; procedure TForm1.OnServiceConnectionChange(Sender: TObject; PushChanges: TPushService.TChanges); var PushService: TPushService; begin PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM); if TPushService.TChange.DeviceToken in PushChanges then begin FDeviceToken := PushService.DeviceTokenValue[TPushService.TDeviceTokenNames.DeviceToken]; MemoLog.Lines.Add('FireBase Token: ' + FDeviceToken); Log.d('Firebase device token: token=' + FDeviceToken); end; if (TPushService.TChange.Status in PushChanges) and (PushService.Status = TPushService.TStatus.StartupError) then MemoLog.Lines.Add('Error: ' + PushService.StartupError); end; procedure TForm1.OnReceiveNotificationEvent(Sender: TObject;const ServiceNotification:TPushServiceNotification); begin MemoLog.Lines.Add('-----------------------------------------'); MemoLog.Lines.Add('DataKey = ' + ServiceNotification.DataKey); MemoLog.Lines.Add('Json = ' + ServiceNotification.Json.ToString); MemoLog.Lines.Add('DataObject = ' + ServiceNotification.DataObject.ToString); MemoLog.Lines.Add('---------------------------------------'); end; end.
×
×
  • Создать...