GCM在德尔福西雅图没有BAAS [英] GCM in Delphi Seattle without BAAS
问题描述
我试图在GCM中实施没有BAAS的GCM。我已经看过以前的例子使用桥梁和我的研究,以下应该工作,而不依赖于旧的TGCMReceiver组件。
但是下面的行总是返回nil,我运行这在应用程序启动后点击一个按钮:
pre $ AP $ Service $ = TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM) ;
APushService始终为零。
我的AndroidManifest外观如下:
<?xml version =1.0encoding =utf-8?>
<! - BEGIN_INCLUDE(清单) - >
< manifest xmlns:android =http://schemas.android.com/apk/res/android
package =com.embarcadero.Project1
android:versionCode = 1
android:versionName =1.0.0
android:installLocation =auto>
<! - 这是NativeActivity引入的平台API。 - >
< uses-sdk android:minSdkVersion =14android:targetSdkVersion =14/>
< uses-permission android:name =android.permission.ACCESS_COARSE_LOCATION/>
< uses-permission android:name =android.permission.ACCESS_FINE_LOCATION/>
< uses-permission android:name =android.permission.CALL_PHONE/>
<使用权限android:name =android.permission.CAMERA/>
< uses-permission android:name =android.permission.INTERNET/>
<使用权限android:name =android.permission.READ_CALENDAR/>
<使用权限android:name =android.permission.READ_EXTERNAL_STORAGE/>
<使用权限android:name =android.permission.READ_PHONE_STATE/>
<使用权限android:name =android.permission.WAKE_LOCK/>
<使用权限android:name =android.permission.WRITE_CALENDAR/>
< uses-permission android:name =android.permission.WRITE_EXTERNAL_STORAGE/>
<使用权限android:name =android.permission.GET_ACCOUNTS/>
< permission android:name =com.embarcadero.Project1.permission.C2D_MESSAGEandroid:protectionLevel =signature/>
<使用权限android:name =com.embarcadero.Project1.permission.C2D_MESSAGE/>
< uses-permission android:name =com.google.android.c2dm.permission.RECEIVE/>
< uses-permission android:name =android.permission.ACCESS_NETWORK_STATE/>
< uses-feature android:glEsVersion =0x00020000android:required =True/>
< application android:persistent =False
android:restoreAnyVersion =False
android:label =Project1
android:debuggable =True
android:largeHeap =False
android:icon =@ drawable / ic_launcher
android:theme =@ style / AppTheme
android:hardwareAccelerated =true>
< meta-data android:name =com.google.android.gms.versionandroid:value =4323000/>
<! - 我们的活动是内置NativeActivity框架类的一个子类。
这将处理与我们NDK代码的集成。 - >
< activity android:name =com.embarcadero.firemonkey.FMXNativeActivity
android:label =Project1
android:configChanges =orientation | keyboard | keyboardHidden | screenSize
android:launchMode =singleTask>
<! - 告诉NativeActivity我们的.so的名称 - >
< meta-data android:name =android.app.lib_name
android:value =Project1/>
< intent-filter>
< category android:name =android.intent.category.LAUNCHER/>
< / intent-filter>
< / activity>
< activity android:name =com.google.android.gms.ads.AdActivityandroid:configChanges =keyboard | keyboardHidden | orientation | screenLayout | uiMode | screenSize | smallestScreenSize/>
< receiver
android:name =com.embarcadero.gcm.notifications.GCMNotificationandroid:exported =true
android:permission =com.google。 android.c2dm.permission.SEND>
< intent-filter>
< category android:name =com.embarcadero.Project1/>
< / intent-filter>
< / receiver>
< receiver android:name =com.embarcadero.rtl.notifications.NotificationAlarm/>
< receiver android:exported =trueandroid:name =com.embarcadero.gcm.notifications.GCMNotificationandroid:permission =com.google.android.c2dm.permission.SEND>
< intent-filter>
< category android:name =com.embarcadero.Project1/>
< / intent-filter>
< / receiver>
< service android:name =com.embarcadero.gcm.notifications.GCMIntentService/>
< / application>
< / manifest>
<! - END_INCLUDE(清单) - >
我已经尝试使用CodeRage9中使用XE8的常见TGCMReceiver应用程序,它没有在XE10 /西雅图工作,看起来XE10在这方面进行了更新,但我无法使用简单的Google Cloud Messaging进行任何操作,并且正在寻找一些指导。
解决方案答案显示在这里:问题与GCM推送通知服务DELPHI XE6
除了.Active:= True而不是AutoActivate:= True,如答案所示。
TL; DR版本。将表单上的TKinvyProvider放在只填充GCMAppID的表单上,将表单上的TPushEvent设置为AutoRegister和AutoActivate设置为false。在授权清单中设置support push notification:true..将以下内容添加到您的AndroidManifest.template.xml中:
<< ; service android:name =com.embarcadero.gcm.notifications.GCMIntentService/>
就在< / application>
之前。
I am trying to implement GCM without BAAS in GCM. I have looked at previous examples using the bridge and from my research the following should work without relying on the old TGCMReceiver component.
But the following line always returns nil, I run this after the application starts up on a button click:
APushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM);
APushService is always nil.
My AndroidManifest looks as follows:
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.embarcadero.Project1"
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.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<permission android:name="com.embarcadero.Project1.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.embarcadero.Project1.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:glEsVersion="0x00020000" android:required="True"/>
<application android:persistent="False"
android:restoreAnyVersion="False"
android:label="Project1"
android:debuggable="True"
android:largeHeap="False"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true">
<meta-data android:name="com.google.android.gms.version" android:value="4323000" />
<!-- 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="Project1"
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="Project1" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<receiver
android:name="com.embarcadero.gcm.notifications.GCMNotification" android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.embarcadero.Project1" />
</intent-filter>
</receiver>
<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="com.embarcadero.Project1" />
</intent-filter>
</receiver>
<service android:name="com.embarcadero.gcm.notifications.GCMIntentService" />
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->
I have tried using the common TGCMReceiver application that is out there from CodeRage9 using XE8, it doesn't work in XE10 / Seattle and it does appear that XE10 is updated in this regard but I cannot make anything work with simple Google Cloud Messaging and am looking for some guidance.
The answer is shown here: Issue with GCM Push notification service DELPHI XE6
Except with .Active := True not AutoActivate := True as indicated by the Answer.
TL;DR version. Drop TKinvyProvider on form with just the GCMAppID populated, Drop TPushEvent on Form with AutoRegister and AutoActivate set to false. In entitlement list set "support push notification : true".. add in the following to your AndroidManifest.template.xml:
<service android:name="com.embarcadero.gcm.notifications.GCMIntentService" />
Right before </application>
.
这篇关于GCM在德尔福西雅图没有BAAS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!