破晓 发表于 2015-1-24 14:22:47

google推送,googleplay ANE(Android)

google推送,googleplayANE(Android)




google推送服务端.php
<?php
define("GOOGLE_API_KEY", "AIzaSyBtxRXUFoJnXJlkmcqkFWs87kwRE4Y5GRs");

function send_push_notification($registatoin_ids, $message) {
      

      // Set POST variables
      $url = 'https://android.googleapis.com/gcm/send';

      $fields = array(
            'registration_ids' => $registatoin_ids,
            'data' => $message,
      );

      $headers = array(
            'Authorization: key=' . GOOGLE_API_KEY,
            'Content-Type: application/json'
      );
                //print_r($headers);
      // Open connection
      $ch = curl_init();

      // Set the url, number of POST vars, POST data
      curl_setopt($ch, CURLOPT_URL, $url);

      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

      // Disabling SSL Certificate support temporarly
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

      // Execute post
      $result = curl_exec($ch);
      if ($result === FALSE) {
            die('Curl failed: ' . curl_error($ch));
      }

      // Close connection
      curl_close($ch);
      echo $result;
    }
        $registatoin_ids = array("APA91bHUUwpzbsqeXWyZg2gQHaBuI7evfR7Q5_DrnhQ7gqlwLv68Cq346cQAUB4NWX5T3X2FvFfIfwj9ABnf2yFbKamSlmW4AampE3Vo0Mgh8GC1VfFDqRF2tqaqdVEzg6VxQiFgJGX0bSXfMAVKHEAEUYj4Ljoo6-MMCPIIYuPRB4aCPQ7TzxTSaeQmgW0cfuSfh772dPdn");
    $message = array("message"=>"hello world","action"=>"com.antoinecampbell.gcmdemo.ECHO");
        send_push_notification($registatoin_ids,$message);
?>


本资源来自:ANE开源群 307700284

破晓 发表于 2015-1-29 15:43:46

本帖最后由 破晓 于 2015-3-26 14:36 编辑

相关下载:

https://github.com/alextel69/google-play-game-services-ane


http://www.airmyth.com/thread-1255-1-1.html

破晓 发表于 2015-1-30 16:48:53

谷歌云消息/推送通知

Google Cloud Messaging / Push Notification Native Extension for Android


Push Notification ANE for AndroidGCM_ANE - Push Notification Native Extension for Android applications using GCM (Google Cloud Messaging)This ANE based on Afterick's idea.VersionThis is version 1.0 of this extension.Extension ID
<extensionID>com.janumedia.ane.gcm</extensionID>UsageYou will need the Project Number as GCM_SENDER_ID from the Google APIs Console where you enabled GCM. More information about GCM you can start from herevar gcm:GCMExtension; = new GCMExtension();
//trace (GCMExtension.VERSION);
gcm.addEventListener(GCMEvent.REGISTERED, handleRegistered, false, 0, true);
gcm.addEventListener(GCMEvent.UNREGISTERED, handleUnregistered, false, 0, true);
gcm.addEventListener(GCMEvent.MESSAGE, handleMessage, false, 0, true);
gcm.addEventListener(GCMEvent.ERROR, handleError, false, 0, true);
gcm.addEventListener(GCMEvent.RECOVERABLE_ERROR, handleError, false, 0, true);
gcm.register(GCM_SENDER_ID);Make sure to add this permission on your manifest file:<!-- App receives GCM messages. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<permission android:name="air.YOUR_APP_BUNDLE_ID_HERE.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="air.YOUR_APP_BUNDLE_ID_HERE.permission.C2D_MESSAGE" />Add inside Application tag, update YOUR_APP_BUNDLE_ID_HERE.<service android:name="com.janumedia.ane.gcm.GCMPushIntentService" />
<receiver android:name="com.janumedia.ane.gcm.GCMPushBroadcastReceiver" 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="YOUR_APP_BUNDLE_ID_HERE" />
    </intent-filter>
</receiver>AuthorThis ANE has been writen by I Nengah Januartha. It belongs to JanuMedia Inc. and is distributed under theApache Licence, version 2.0.




相关链接:
https://github.com/janumedia/GCM_ANE

破晓 发表于 2015-3-27 15:53:15

谷歌云消息ANE



https://github.com/breealyeska/GCMExtension

破晓 发表于 2015-4-3 16:14:53

本帖最后由 破晓 于 2015-4-3 16:18 编辑

https://github.com/nitacawo/Goog ... Overlawled-examples


Instructions
[*]Well first of all run up to date air sdk :)
[*]Upload apk with google play services implemented in console. You must use the same certificate.



[*]Connect your game with game services(In google developer console>game services>add a new game)

https://github.com/nitacawo/Google-play-freshplanet-Overlawled-examples/raw/master/screenshots/1.png?raw=true
[*]Modify your-app.xml file Package name in console must be with air. and be the same as your app idin xml
<id>TrollBootman</id><android>
      <manifestAdditions><![CDATA[<manifest>
<uses-sdk android:minSdkVersion="9"></uses-sdk>
<application>

            <!-- GooglePlay Games Services -->
            <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ 84364063738" />
            <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
            <activity android:name="com.freshplanet.googleplaygames.SignInActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
      </application>
</manifest>]]></manifestAdditions>
</android>

[*]if your app shows the google play window but fails to connect or crashes check out the issue which might happenGoto Game details scroll down to API CONSOLE PROJECT and click your project name


https://github.com/nitacawo/Google-play-freshplanet-Overlawled-examples/raw/master/screenshots/2.png?raw=true

Check if in api & auth>Credentials> package name is the same as in the developer console

https://github.com/nitacawo/Google-play-freshplanet-Overlawled-examples/raw/master/screenshots/3.png?raw=true

it must be the same as in developer console if it is not go back and add game services again but this time use I already use GOOGLE APIS in my game button, find your app and add.Check again if it shows up properly this time.

https://github.com/nitacawo/Google-play-freshplanet-Overlawled-examples/raw/master/screenshots/4.png?raw=true
*you don't need to publish game services to test it with your own account.

破晓 发表于 2015-4-3 17:11:05

ANE-GooglePlayServices


Adobe AIR ANE Project - this example illustrates a problem, and doesn't work!






ANE-GooglePlayServicesAdobe AIR ANE Project - this example illustrates a problem, and doesn't work!This Android ANE will work if you comment out the GooglePlayServicesUtils references in this file:https://github.com/interactivenyc/ANE-GooglePlayServices/blob/master/SPK-GPS_Java_Eclipse/src/com/speakaboos/ane/gps/testGPS.javaThis project can be built with the ANT script in the SPK-GPS_Build folder. Just navigate to that folder and run "ant buildANE." To build the test GPS.apk file and install it on your Android device, run "ant buildTest." NOTE: You'll need to edit the top of the build.config file to point the script to your FLEX and AIR SDKs, and the location of your local project files.The test GPS.apk has three buttons: testGPS, keepAwake and cancelKeepAwake. The keepAwake functions call native Android Java functions, and work as expected. The testGPS button tries to validate the existence of the google-play-services.jar library using this method, which fails:GooglePlayServicesUtil.isGooglePlayServicesAvailable(context)I've tried to make this as simple as possible, in order to ask for help getting it to work. If you have any questions, please email me at github@speakaboos.com]steve+github@speakaboos.com.There are two different folders for compiling the native JAR file for inclusion in the ANE. I believe the problem lies in the way I'm trying to include the google-play-services.jar file in my project. I've tried including it from the libs folder in the Eclipse version. I've tried combining it with my own jar file. I've tried using AndroidStudio and Gradle to see if their way of including a module would help. I've used a platformoptions file to see if AIR could include the library that way too. I'm out of ideas.'



相关链接:

https://github.com/interactivenyc/ANE-GooglePlayServices

破晓 发表于 2015-4-8 16:32:06

ANE-GooglePlayServices

Shared library including the Google Play Services Library

https://github.com/distriqt/ANE-GooglePlayServices

lxz 发表于 2017-10-24 03:13:46

感谢分享!~
页: [1]
查看完整版本: google推送,googleplay ANE(Android)