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
Moderator: 2ffat
#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("---------------------------------------"));
}
Lena wrote:Please tell me where I will see this entry:
Log::d(_D("Firebase device token: token=") + FDeviceToken);
Displays a message in the Event Log.
rlebeau wrote:Lena wrote:Please tell me where I will see this entry:
Log::d(_D("Firebase device token: token=") + FDeviceToken);
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.
Sparow wrote: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.
Users browsing this forum: No registered users and 11 guests