2016-02-23 50 views
2

我想在GCM中實現沒有BAAS的GCM。我已經看過使用橋接器的前面的例子,並且從我的研究中,以下應該可以工作而不依賴於舊的TGCMReceiver組件。德爾福西雅圖GCM在沒有BAAS的情況下

但是下面一行總是返回零,我運行這個應用程序啓動時的一個按鈕點擊後:

APushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM); 

APushService始終是零。

我AndroidManifest如下所示:

<?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) --> 

我已經使用普通TGCMReceiver應用程序,在那裏使用XE8 CodeRage9試過,不XE10 /西雅圖工作,但看來XE10是在這方面進行了更新,但我無法使用簡單的Google Cloud Messaging進行任何操作,並且正在尋找一些指導。

+0

我也嘗試過在這裏爲XE 6指出的內容。http://stackoverflow.com/questions/25205478/issue-with-gcm-push-notification-service-delphi-xe6/27690786 – FerretDriver

回答

1

答案如下所示:Issue with GCM Push notification service DELPHI XE6

除經。主動:=真不AutoActivate:由應答指示=真。

TL; DR版本。將表單上的TKinvyProvider放在只填充GCMAppID的表單上,將表單上的TPushEvent設置爲AutoRegister和AutoActivate設置爲false。在設置「支持推送通知:真正的」權利清單:</application>之前

<service android:name="com.embarcadero.gcm.notifications.GCMIntentService" /> 

的權利..添加以下到您AndroidManifest.template.xml。

相關問題