Перейти к содержанию
Fire Monkey от А до Я

Kitty

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

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

  • Посещение

  • Победитель дней

    16

Весь контент Kitty

  1. Я пытаюсь адаптировать статью этого топика. Т.е в статье присутствует .pas файл с нужным функционалом. Как этот файл будут выглядеть в окончательном виде с THTTPClient?
  2. Скажите вот так будет правильно? procedure RegisterDevice(DeviceID : string; DeviceToken : string); var // Данные для передачи скрипту postdata: TStringList; // Подключение для передачи данных httpconnect : TIdHTTP; begin try // Создаём подключение httpconnect := TIdHTTP.Create; // Указываем данные для отправки postdata := TStringList.Create; postdata.Add('action=register-device'); postdata.Add('did=' + DeviceID); postdata.Add('token=' + DeviceToken); {$ifdef ANDROID} postdata.Add('platform=android'); {$else} postdata.Add('platform=ios'); {$endif} // Отправляем запрос httpconnect.Post(DOMAIN + 'push.php', postdata); finally // Отключаемся и освобождаем память httpconnect.Disconnect; httpconnect.DisposeOf; IF Assigned( postdata ) THEN BEGIN postdata.DisposeOf; postdata := Nil; END; end; end; Просто в С++ я использую при объявлении умный указатель unique_ptr и меня не волнует освобождение памяти т.к. этот указатель сам все делает и за всем следит когда освобождать правильно память. И остаеться вопрос, как в моем случае правильно объявить const // Доменное имя сайта DOMAIN: string = ? Спасибо.
  3. Заполняю в консоли поле Текст сообщения и Название сообщения. В дополнительных параметрах есть Заголовок и Ключ-Значение тоже все заполнено. Не помогло. Как добавить поле message?
  4. Прежде чем создавать свой PHP сервер, хочу протестировать свое приложение отправкой пуша из консоли firebase. Иду по этой статье: Firebase Cloud Messaging with Delphi 10.1 Berlin update 2 У автора в статье все нормально, а у меня нет... Весь код: //H #include <System.PushNotification.hpp> private: // User declarations TPushService * APushService; TPushServiceConnection * AServiceConnection; //*********************************************** //CPP #if defined(__ANDROID__) #include <FMX.PushNotification.Android.hpp> namespace Fmx { namespace Pushnotification { namespace Android { _INIT_UNIT(Fmx_Pushnotification_Android); } } } #endif #if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) #include <FMX.PushNotification.IOS.hpp> namespace Fmx { namespace Pushnotification { namespace Ios { _INIT_UNIT(Fmx_Pushnotification_Ios); } } } #endif void __fastcall TForm1::FormShow(TObject *Sender) { APushService = nullptr; AServiceConnection = nullptr; String ADeviceID = ""; String ADeviceToken = ""; #if defined(__ANDROID__) APushService = TPushServiceManager::Instance->GetServiceByName(TPushService_TServiceNames_GCM); if (APushService) APushService->AppProps[TPushService_TAppPropNames_GCMAppID] = FAndroidServerKey; #endif #if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) APushService = TPushServiceManager::Instance->GetServiceByName(TPushService_TServiceNames_APS); #endif if (APushService) { AServiceConnection = new TPushServiceConnection(APushService); AServiceConnection->OnChange = &OnServiceConnectionChange; AServiceConnection->OnReceiveNotification = &OnReceiveNotificationEvent; AServiceConnection->Active = true; } } void __fastcall TForm1::OnReceiveNotificationEvent(TObject *Sender, TPushServiceNotification* const ANotification) { // ShowMessage(ANotification->Json->ToString()); String MessageText = ""; // Получаем текст сообщения в зависимости от платформы #if defined(__ANDROID__) MessageText = ANotification->DataObject->GetValue("message")->Value(); #endif #if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) MessageText = ANotification->DataObject->GetValue("alert")->Value(); #endif if (MessageText != "") ShowNotification(MessageText, 0); //объявлен в файле pas } Отправляю пуш из консоли firebase. Спустя несколько минут пуш приходит на телефон. Видно название приложения, а сам текст пуша пустой. При нажатии на пуш в шторке получаем: segmentation fault 11 на строке: MessageText = ANotification->DataObject->GetValue("message")->Value(); Где может быть ошибка получения пуша из консоли firebase? У автора на картинках все гуд...
  5. Проблема с билдером решена и он может теперь работать с пушами. Источник: как исправить баг У меня вопрос по статье. Вот в статье есть код: const // Доменное имя сайта DOMAIN: string = '193.106.248.115'; implementation procedure RegisterDevice(DeviceID : string; DeviceToken : string); var // Данные для передачи скрипту postdata: TStringList; // Подключение для передачи данных httpconnect : TIdHTTP; begin try // Создаём подключение httpconnect := TIdHTTP.Create; // Указываем данные для отправки postdata := TStringList.Create; postdata.Add('action=register-device'); postdata.Add('did=' + DeviceID); postdata.Add('token=' + DeviceToken); {$ifdef ANDROID} postdata.Add('platform=android'); {$else} postdata.Add('platform=ios'); {$endif} // Отправляем запрос httpconnect.Post(DOMAIN + 'push.php', postdata); finally // Отключаемся и освобождаем память httpconnect.Disconnect; httpconnect.DisposeOf; end; end; Два вопроса: У меня, к примеру, весь PHP сервер скопирован в корень 193.106.248.115 в папку Push_Server. 1. Мне надо объявить константу так? -> const // Доменное имя сайта DOMAIN: string = '193.106.248.115/Push_Server'; или как? 2. Не знаю паскаль. Почему нет освобождения памяти для postdata? postdata := TStringList.Create;
  6. Эмбаркадеро забыло включить в соответствующие Н файлы необходимые инструкции: _INIT_UNIT(Fmx_Pushnotification_Android); //для андроида _INIT_UNIT(Fmx_Pushnotification_Ios); //для ios Поэтому решением является вместо кода: #if defined(_ANDROID_) #include <FMX.PushNotification.Android.hpp> #endif #if defined(_APPLE) && (defined(arm) || defined(arm64_)) #include <FMX.PushNotification.IOS.hpp> #endif Написать код включения этих строк кода с учетом пространства имен: #if defined(__ANDROID__) #include <FMX.PushNotification.Android.hpp> namespace Fmx { namespace Pushnotification { namespace Android { _INIT_UNIT(Fmx_Pushnotification_Android); } } } #endif #if defined(_APPLE) && (defined(arm) || defined(arm64_)) #include <FMX.PushNotification.IOS.hpp> namespace Fmx { namespace Pushnotification { namespace Ios { _INIT_UNIT(Fmx_Pushnotification_Ios); } } } #endif Если бы Равиль не исследовал эту проблему, я бы не написала в тех.поддержку и билдер был бы в пролете с пушами...:)
  7. Спасибо трем проголосовавшим. Решение найдено.
  8. Некто Bruneau Babet ответил в голосовании, а оно все равно не работает... https://quality.embarcadero.com/browse/RSP-17714
  9. Спасибо за голосование! У меня были сомнения или это моя тупость или баг ембаркадеро. Но поскольку Равиль подтвердил, то это баг эмбаркадеро. Этот баг отрезает билдер от серьёзной разработки с пушами...
  10. Просьба проголосовать, может эмбакадеро предложит фикс: https://quality.embarcadero.com/browse/RSP-17714 Спасибо.
  11. У меня есть только две версии происходящего: 1. Это очередной баг эмбаркадеро. Как бороться неизвестно. 2. Этой строки APushService = TPushServiceManager::Instance->GetServiceByName(TPushService_TServiceNames_GCM); не достаточно для инициализации APushService и для билдера требуется какой то хитрый не документированы не где способ... что также говорит об уровне справочной системы...
  12. А мне не помогло, в андроид проекте APushService все время NIL #include <System.PushNotification.hpp> private TPushService * APushService; TPushServiceConnection * AServiceConnection; #include <System.PushNotification.hpp> #if defined(__ANDROID__) #include <FMX.PushNotification.Android.hpp> #endif #if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) #include <FMX.PushNotification.IOS.hpp> #endif const String FAndroidServerKey = L"820629486434"; void __fastcall TForm1::Button1Click(TObject *Sender) { APushService = nullptr; AServiceConnection = nullptr; #if defined(__ANDROID__) APushService = TPushServiceManager::Instance->GetServiceByName(TPushService_TServiceNames_GCM); //NULL!!! APushService->AppProps[TPushService_TAppPropNames_GCMAppID] = FAndroidServerKey;//Error: segmentation fault 11 #endif }
  13. А шаманство, о котором рассказывает Ярослав в своих курсах о правке стилей, тоже исправили? Ручная правка чтобы увидеть точки деформации...
  14. Вроде тут похожая проблема: APushService is always nil только не поняла, а что же надо сделать?... Мой манифест в общей папке проекта AndroidManifest.template.xml: <?xml version="1.0" encoding="utf-8"?> <!-- BEGIN_INCLUDE(manifest) --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="%package%" android:versionCode="%versionCode%" android:versionName="%versionName%" android:installLocation="%installLocation%"> <!-- This is the platform API where NativeActivity was introduced. --> <uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="%targetSdkVersion%" /> <%uses-permission%> <uses-feature android:glEsVersion="0x00020000" android:required="True"/> <application android:persistent="%persistent%" android:restoreAnyVersion="%restoreAnyVersion%" android:label="%label%" android:debuggable="%debuggable%" android:largeHeap="%largeHeap%" android:icon="%icon%" android:theme="%theme%" android:hardwareAccelerated="%hardwareAccelerated%"> <%application-meta-data%> <%services%> <!-- Our activity is a subclass of the built-in NativeActivity framework class. This will take care of integrating with our NDK code. --> <activity android:name="com.embarcadero.firemonkey.FMXNativeActivity" android:label="%activityLabel%" android:configChanges="orientation|keyboard|keyboardHidden|screenSize" android:launchMode="singleTask"> <!-- Tell NativeActivity the name of our .so --> <meta-data android:name="android.app.lib_name" android:value="%libNameValue%" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <%activity%> <service android:name="com.embarcadero.gcm.notifications.GCMIntentService" /> <%receivers%> </application> </manifest> <!-- END_INCLUDE(manifest) --> А такой манифест AndroidManifest.xml в паке релиз: <?xml version="1.0" encoding="utf-8"?> <!-- BEGIN_INCLUDE(manifest) --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ua.com.mikros.Promo" android:versionCode="1" android:versionName="1.0.0" android:installLocation="auto"> <!-- This is the platform API where NativeActivity was introduced. --> <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <permission android:name="ua.com.mikros.Promo.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="ua.com.mikros.Promo.permission.C2D_MESSAGE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-feature android:glEsVersion="0x00020000" android:required="True"/> <application android:persistent="False" android:restoreAnyVersion="False" android:label="Promo" android:debuggable="True" android:largeHeap="False" android:icon="@drawable/ic_launcher" android:theme="@style/AppTheme" android:hardwareAccelerated="true"> <!-- Our activity is a subclass of the built-in NativeActivity framework class. This will take care of integrating with our NDK code. --> <activity android:name="com.embarcadero.firemonkey.FMXNativeActivity" android:label="Promo" android:configChanges="orientation|keyboard|keyboardHidden|screenSize" android:launchMode="singleTask"> <!-- Tell NativeActivity the name of our .so --> <meta-data android:name="android.app.lib_name" android:value="Promo" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:name="com.embarcadero.gcm.notifications.GCMIntentService" /> <receiver android:name="com.embarcadero.rtl.notifications.NotificationAlarm" /> <receiver android:exported="true" android:name="com.embarcadero.gcm.notifications.GCMNotification" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="ua.com.mikros.Promo" /> </intent-filter> </receiver> </application> </manifest> <!-- END_INCLUDE(manifest) -->
  15. Добавила. Видимо еще какая-то настройка мною упущена. APushService = 0х0...
  16. А в опциях проекта в окне разрешений какие галочки должны стоять? У меня там все галочки сброшены.
  17. segmentation fault 11 Ничего не помогает, все настроено так как в статье...
  18. //h #include <System.PushNotification.hpp> //cpp #if defined(__ANDROID__) #include <FMX.PushNotification.Android.hpp> #endif #if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) #include <FMX.PushNotification.IOS.hpp> #endif segmentation fault 11 и попадаем в файл System.PushNotification на строки procedure TPushService.SetAppProp(const AName, AValue: string); begin FAppProps.AddOrSetValue(AName, AValue); end; Что можно еще посоветовать? Спасибо.
  19. Подскажите, пожалуйста, в чем может быть проблема? На строке: APushService->AppProps[TPushService_TAppPropNames_GCMAppID] = FAndroidServerKey; Ошибка: segmentation fault 11 TForm1 *Form1; const String FAndroidServerKey = L"875940064719"; void __fastcall TForm1::FormShow(TObject *Sender) { APushService = nullptr; AServiceConnection = nullptr; String ADeviceID = ""; String ADeviceToken = ""; #if defined(__ANDROID__) APushService = TPushServiceManager::Instance->GetServiceByName(TPushService_TServiceNames_GCM); APushService->AppProps[TPushService_TAppPropNames_GCMAppID] = FAndroidServerKey; #endif #if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) APushService = TPushServiceManager::Instance->GetServiceByName(TPushService_TServiceNames_APS); #endif if (APushService) { AServiceConnection = new TPushServiceConnection(APushService); AServiceConnection->OnChange = &OnServiceConnectionChange; AServiceConnection->OnReceiveNotification = &OnReceiveNotificationEvent; AServiceConnection->Active = true; ADeviceID = APushService->DeviceIDValue[TPushService_TDeviceIDNames_DeviceID]; ADeviceToken = APushService->DeviceTokenValue[TPushService_TDeviceTokenNames_DeviceToken]; if(ADeviceID != "" && ADeviceToken != "") { RegisterDevice(ADeviceID, ADeviceToken); //global.hpp } } } Весь код: void __fastcall OnReceiveNotificationEvent(TObject *Sender, TPushServiceNotification* const ANotification); void __fastcall OnServiceConnectionChange(TObject *Sender, TPushService::TChanges AChange); private: // User declarations TPushService * APushService; TPushServiceConnection * AServiceConnection; //cpp void __fastcall TForm1::FormShow(TObject *Sender) { APushService = nullptr; AServiceConnection = nullptr; String ADeviceID = ""; String ADeviceToken = ""; #if defined(__ANDROID__) APushService = TPushServiceManager::Instance->GetServiceByName(TPushService_TServiceNames_GCM); APushService->AppProps[TPushService_TAppPropNames_GCMAppID] = FAndroidServerKey; #endif #if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) APushService = TPushServiceManager::Instance->GetServiceByName(TPushService_TServiceNames_APS); #endif if (APushService) { AServiceConnection = new TPushServiceConnection(APushService); AServiceConnection->OnChange = &OnServiceConnectionChange; AServiceConnection->OnReceiveNotification = &OnReceiveNotificationEvent; AServiceConnection->Active = true; ADeviceID = APushService->DeviceIDValue[TPushService_TDeviceIDNames_DeviceID]; ADeviceToken = APushService->DeviceTokenValue[TPushService_TDeviceTokenNames_DeviceToken]; if(ADeviceID != "" && ADeviceToken != "") { RegisterDevice(ADeviceID, ADeviceToken); //global.hpp } } } //--------------------------------------------------------------------------- void __fastcall TForm1::OnServiceConnectionChange(TObject *Sender, TPushService::TChanges AChange) { if (AChange.Contains(TPushService::TChange::DeviceToken) && (AServiceConnection)) { String ADeviceID = ""; String ADeviceToken = ""; ADeviceID = APushService->DeviceIDValue[TPushService_TDeviceIDNames_DeviceID]; ADeviceToken = APushService->DeviceTokenValue[TPushService_TDeviceTokenNames_DeviceToken]; if(ADeviceID != "" && ADeviceToken != "") { RegisterDevice(ADeviceID, ADeviceToken); //global.hpp } } } //--------------------------------------------------------------------------- void __fastcall TForm1::OnReceiveNotificationEvent(TObject *Sender, TPushServiceNotification* const ANotification) { //ShowMessage(ANotification->Json->ToString()); String MessageText = ""; //Получаем текст сообщения в зависимости ль платформы #if defined(__ANDROID__) MessageText = ANotification->DataObject->GetValue("message")->Value(); #endif #if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) MessageText = ANotification->DataObject->GetValue("alert")->Value(); #endif if(MessageText != "") ShowNotification(MessageText, 0); }
  20. Это за 2017 год не то?: SSL
  21. List of new features and customer reported issues fixed in RAD Studio 10.2 Tokyo
  22. Kitty

    Session ended

    ААА! Значит на телефон устанавливаться нужный проект? Просто я смотрю на телефон, а там нет запуска приложения из студии... при компиляции.
  23. Выполнив рекомендации Евгения Корепова, удалось заблокированное приложение удалить. Спасибо!
×
×
  • Создать...