Hello.
Can anyone translate this code into C++?
I do not understand for example:
if (TPushService.TChange.Status in PushChanges)...
http://docwiki.embarcadero.com/RADStudi ... id_Support
Firebase Android Support C++ code?
Moderator: 2ffat
Re: Firebase Android Support C++ code?
Something like this:
Code: Select all
#include <FMX.PushNotification.Android.hpp>
...
class TFormMain : public TForm
{
__published:
TMemo *MemoLog;
...
private:
String FDeviceId;
String FDeviceToken;
...
void __fastcall OnServiceConnectionChange(TObject* Sender, TPushService::TChanges PushChanges);
void __fastcall OnReceiveNotificationEvent(TObject* Sender, TPushServiceNotification* const ANotification);
...
public:
__fastcall TFormMain(TComponent *Owner);
...
};
...
__fastcall TFormMain::TFormMain(TComponent *Owner)
: TForm(Owner)
{
TPushService *PushService = TPushServiceManager::Instance->GetServiceByName(TPushService_TServiceNames_GCM);
TPushServiceConnection *ServiceConnection = new TPushServiceConnection(PushService);
ServiceConnection->Active = true;
ServiceConnection->OnChange = &OnServiceConnectionChange;
ServiceConnection->OnReceiveNotification = &OnReceiveNotificationEvent;
FDeviceId = PushService->DeviceIDValue[TPushService_TDeviceIDNames_DeviceID];
MemoLog->Lines->Add(_D("DeviceID: ") + FDeviceId);
MemoLog->Lines->Add(_D("Ready to receive!"));
// Checks notification on startup, if application was launched from cold start
// by tapping on Notification in Notification Center
DynamicArray<TPushServiceNotification*> Notifications = PushService->StartupNotifications;
if (Notifications.Length > 0)
{
MemoLog->Lines->Add(_D("-----------------------------------------");
MemoLog->Lines->Add(_D("DataKey = ") + Notifications[0]->DataKey);
MemoLog->Lines->Add(_D("Json = ") + Notifications[0]->Json->ToString());
MemoLog->Lines->Add(_D("DataObject = ") + Notifications[0]->DataObject->ToString());
MemoLog->Lines->Add(_D("-----------------------------------------"));
// alternatively:
// for(TPushServiceNotification* notification : Notifications)
// OnReceiveNotificationEvent(nullptr, notification);
}
}
void __fastcall TFormMain::OnServiceConnectionChange(TObject* Sender, TPushService::TChanges PushChanges)
{
TPushService *PushService = TPushServiceManager::Instance->GetServiceByName(TPushService_TServiceNames_GCM);
if (PushChanges.Contains(TPushService::TChange::DeviceToken))
{
FDeviceToken = PushService->DeviceTokenValue[TPushService_TDeviceTokenNames_DeviceToken];
MemoLog->Lines->Add(_D("FireBase Token: ") + FDeviceToken);
Log::d(_D("Firebase device token: token=") + FDeviceToken);
}
if (PushChanges.Contains(TPushService::TChange::Status) && PushService->Status.Contains(TPushService::TStatus::StartupError))
MemoLog->Lines->Add(_D("Error: ") + PushService->StartupError);
}
void __fastcall TFormMain::OnReceiveNotificationEvent(TObject* Sender, TPushServiceNotification* const ANotification)
{
MemoLog->Lines->Add(_D("-----------------------------------------"));
MemoLog->Lines->Add(_D("DataKey = ") + ServiceNotification->DataKey);
MemoLog->Lines->Add(_D("Json = ") + ServiceNotification->Json->ToString());
MemoLog->Lines->Add(_D("DataObject = ") + ServiceNotification->DataObject->ToString());
MemoLog->Lines->Add(_D("---------------------------------------"));
}
Remy Lebeau (TeamB)
Lebeau Software
Lebeau Software
Re: Firebase Android Support C++ code?
Thank You very much for Your help!
Please tell me where I will see this entry:
Log::d(_D("Firebase device token: token=") + FDeviceToken);
Please tell me where I will see this entry:
Log::d(_D("Firebase device token: token=") + FDeviceToken);
Re: Firebase Android Support C++ code?
Per http://docwiki.embarcadero.com/Libraries/en/FMX.Types.Log.d:Lena wrote:Please tell me where I will see this entry:
Log::d(_D("Firebase device token: token=") + FDeviceToken);
IOW, in the IDE's own Events window.Displays a message in the Event Log.
Remy Lebeau (TeamB)
Lebeau Software
Lebeau Software
Re: Firebase Android Support C++ code?
Thank You very much!
Re: Firebase Android Support C++ code?
@rlebeau: In article http://docwiki.embarcadero.com/RADStudi ... id_Support I see "Services" in Project Options dialog. It allows developer to import google-services.json. However in my 10.3.2 C++ Builder Community I don't see such item, so I have no idea how to import google-services.json.rlebeau wrote:Lena wrote:Please tell me where I will see this entry:
Log::d(_D("Firebase device token: token=") + FDeviceToken);
For now my app crashes at startup with error java.lang.RuntimeException: Unable to get provider com.embarcadero.firebase.provider.FirebaseInitProvider: java.lang.IllegalStateException: ApplicationId must be set, I suspect the json must be imported first.
Pls give me some clues, thank you very much.
Re: Firebase Android Support C++ code?
May be this bag
viewtopic.php?f=10&t=3254
viewtopic.php?f=10&t=3254
Re: Firebase Android Support C++ code?
Yes you're correct, thanks @Lena. This is a bug.
I'm about to ditch C++ Builder for good. I started with C++ Builder 3 months ago, nearly completed multi-device app, but now I'm thinking about rewriting everything in native. FMX idea is excellent, but implementation is worse of the worse. Now I cannot even publish Android app to Play Store due to lack of 64bit support.
@Lena: I have a question: do you have any serious problem with C++ Builder multi-device apps (beside no 64 bit Android)? Thanks again.
I'm about to ditch C++ Builder for good. I started with C++ Builder 3 months ago, nearly completed multi-device app, but now I'm thinking about rewriting everything in native. FMX idea is excellent, but implementation is worse of the worse. Now I cannot even publish Android app to Play Store due to lack of 64bit support.
@Lena: I have a question: do you have any serious problem with C++ Builder multi-device apps (beside no 64 bit Android)? Thanks again.
Re: Firebase Android Support C++ code?
Yeah, I'm not a big fan of FMX, either. But I use C++Builder only for Windows development, and VCL rocks for that platform.Sparow wrote:I'm about to ditch C++ Builder for good. I started with C++ Builder 3 months ago, nearly completed multi-device app, but now I'm thinking about rewriting everything in native. FMX idea is excellent, but implementation is worse of the worse.
C++Builder support for 64-bit Android is not going to be available until at least mid-2020. Delphi support for 64-bit Android is currently in beta, though. If you had an existing 32-bit app in the Play Store before the August 1 2019 deadline, you can request an extension from Google to continue posting updates to that 32-bit app until August 2020 without adding 64-bit support. But after August 2020, 64-bit is a MUST, hopefully C++Builder will be ready by then.Sparow wrote:Now I cannot even publish Android app to Play Store due to lack of 64bit support.
Remy Lebeau (TeamB)
Lebeau Software
Lebeau Software
Re: Firebase Android Support C++ code?
No.@Lena: I have a question: do you have any serious problem with C++ Builder multi-device apps (beside no 64 bit Android)? Thanks again.
Re: Firebase Android Support C++ code?
I additionally use this resource: http://fire-monkey.ru/ There is some useful information. You can use English.
There's the truth 90% of the code to Delphi. Sometimes rlebeau helps me to translate to C++
There's the truth 90% of the code to Delphi. Sometimes rlebeau helps me to translate to C++