Delphi Can
Apk olarak çalışıyor fakat google play'e atınca çalışmıyor - Baskı Önizleme

+- Delphi Can (https://www.delphican.com)
+-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3)
+--- Forum: Mobil Platform - FireMonkey (FMX) (https://www.delphican.com/forumdisplay.php?fid=7)
+--- Konu Başlığı: Apk olarak çalışıyor fakat google play'e atınca çalışmıyor (/showthread.php?tid=4945)



Apk olarak çalışıyor fakat google play'e atınca çalışmıyor - arsl01 - 10-06-2020

Merhaba,

Başlıktada belirttiğim gibi bir Arkaplan servisi yazdım Telefona apk olarak yüklediğimde çok güzel çalışıyor, Google playe attım ve arka plan servisi etkin çalışıyor ama bildirim gelmiyor neden olabilir?

unit Uservis;

interface

uses
 System.SysUtils,
 System.Classes,
 System.Android.Service,
 AndroidApi.JNI.GraphicsContentViewText,
 AndroidApi.JNI.Os, System.Notification, REST.Types, REST.Client, Data.Bind.Components, Data.Bind.ObjectScope,
 AndroidApi.Helpers,
 AndroidApi.JNI.App, System.Net.HttpClient, System.Net.HttpClientComponent, inifiles, System.IOUtils;

type
 TDMm = class(TAndroidService)
   NotificationC: TNotificationCenter;
   procedure AndroidServiceCreate(Sender: TObject);
   function AndroidServiceStartCommand(const Sender: TObject; const Intent: JIntent; Flags, StartId: Integer): Integer;
 private
   procedure NotificationCreate;
   procedure ThreadingProcRun(const ARunProc: TProc; const SleepMilliSecond: Integer);
   { Private declarations }
 public
   { Public declarations }
 end;

var
 DMm: TDMm;

implementation

{%CLASSGROUP 'FMX.Controls.TControl'}
{$R *.dfm}

uses NetworkState, RootUnit;

procedure TDMm.AndroidServiceCreate(Sender: TObject);
begin
 ThreadingProcRun(NotificationCreate, 5000);
end;

function TDMm.AndroidServiceStartCommand(const Sender: TObject; const Intent: JIntent; Flags, StartId: Integer): Integer;
begin
 Result := TJService.JavaClass.START_STICKY;

end;

procedure TDMm.NotificationCreate;
var
 xNotification: TNotification;
 NS: TNetworkState;
 A: TRootDTO;
 NetHTTPClient: TNetHTTPClient;
 rsp: IHTTPResponse;
 cevap: String;
 ini1: TINIFile;
 i: integer;
 recordd: integer;
 Token: string;
 Adi: string;
begin

 A := TRootDTO.Create;
 NS := TNetworkState.Create;
 if not NS.IsConnected then
 begin
   NS.Free;
   exit;
 end;

 ini1 := Tinifile.Create(TPath.Combine(TPath.GetDocumentsPath, 'NorthPlus.ini'));
 recordd := (ini1.ReadString('ArkaPlan', 'Record', '').ToInteger) - 1;

 for I := 0 to recordd do
 begin
   Token := ini1.ReadString('ArkaPlan', i.ToString + 'Token', '');
   Adi := ini1.ReadString('ArkaPlan', i.ToString + 'Adi', '');
   NetHTTPClient := TNetHTTPClient.Create(nil);
   try
     try
       rsp := NetHTTPClient.Get('http://31.192.215.124/BL.php?token=' + Token);
     except
       rsp := NetHTTPClient.Get('http://31.192.215.124/BL.php?token=' + Token);
     end;
     cevap := rsp.ContentAsString();
     A.AsJson := cevap;
   finally
     NetHTTPClient.Free;
   end;

   xNotification := NotificationC.CreateNotification;
   if A.BD_15 = '1' then
   begin
     xNotification.Title := Adi;
     xNotification.AlertBody := 'ozelmesaj!';
     NotificationC.PresentNotification(xNotification);
     xNotification.DisposeOf;
   end;

   if A.BD_14 = '1' then
   begin
     xNotification.Title := Adi;
     xNotification.AlertBody := 'motor!';
     NotificationC.PresentNotification(xNotification);
     xNotification.DisposeOf;
   end;
 end;
end;

procedure TDMm.ThreadingProcRun(const ARunProc: TProc; const SleepMilliSecond: Integer);
begin
 TThread.CreateAnonymousThread(
   procedure()
   begin
     while True do
     begin
       ARunProc;
       sleep(SleepMilliSecond);
     end;
   end).Start;
end;

end.



Cvp: Apk olarak çalışıyor fakat google play'e atınca çalışmıyor - Fesih ARSLAN - 10-06-2020

Merhaba,
Algoritmada bir sorun göremedim.
Bir ihtimal A class'ının değerleri set edilmediği (REST'ten yanıt alamamış veya doğru sonuç gelmemiş ise) zaman nil sonucunu alabilirsiniz. 
Bu kontrolü yaptıktan sonra işlem adımları devam ederse daha sağlıklı olabilir. Aksi durumda asenkron çalışan bir metod mobil mimaride hata üretmen kırılır.


Apk olarak çalışıyor fakat google play'e atınca çalışmıyor - arsl01 - 10-06-2020

anladım hocam bilgi için teşekkür ederim