如何注册我的Andr​​oid应用解析网站 [英] How to register my android app to parse site

查看:178
本文介绍了如何注册我的Andr​​oid应用解析网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该如何注册我的Andr​​oid应用(或)设备来解析推网站获得通知。
我现在连接到GCM。
我不能够领先一步,并注册设备与解析...

How should i register my android app (or) device to parse push site to get the notification. now i was connected to GCM. am not able to step ahead and register my device with parse...

推荐答案

下面是实现官方解析SDK的基础上的我的经验几个试错的标准推送通知的最佳方法许多SO和解析线程阅读即可。因此,我将指导您完成这些步骤:

Here's the best way to implement official Parse SDK for standard push notification based on my experiences and several trial and errors and also many SO and Parse threads reading. So I'll walk you through these steps:


  1. 以下的依赖添加到应用程序的build.gradle文件,并且你可以从解析github上空白的项目,或从的文档的网站类别。最新版本到现在为止是在这里:

  1. Add the following dependencies to the app build.gradle file, and you can get the latest versions from Parse github blank projects or Parse SDK from docs category in the website. the latest versions until now is here:

compile 'com.parse.bolts:bolts-tasks:1.3.0'
compile 'com.parse:parse-android:1.11.0'


  • 添加以下codeS类似项目的应用类的的onCreate()方法的快速指南,修改相应的键
    - > 拍摄)注意,这两条线必须经过 super.onCreate(添加;

  • Add the following codes similar to the quick guide in the Application class's onCreate() method of the project, change the keys accordingly --> Take attention that these two lines must be added after super.onCreate(); :

    // Enable Local Datastore.
    Parse.enableLocalDatastore(this);
    
    // Add your initialization code here
    Parse.initialize(this, "YOUR APPLICATION ID", "YOUR CLIENT KEY");
    ParseInstallation.getCurrentInstallation().saveInBackground();
    
    ParseUser.enableAutomaticUser();
    ParseACL defaultACL = new ParseACL();
    // Optionally enable public read access.
    // defaultACL.setPublicReadAccess(true);
    ParseACL.setDefaultACL(defaultACL, true);
    


  • 的setContentView 添加下面一行在你MainActivity类别:

  • Add the following line after setContentView in your MainActivity class:

    ParseAnalytics.trackAppOpenedInBackground(getIntent());
    


  • 立即之前添加解析服务,并接收到AndroidManifest.xml中结束< /用途> 标记,并等同于你所提到的软件包名称:

  • add the Parse service and receivers to AndroidManifest.xml immediately before the closing </application> tag and make the mentioned package names identical to the yours:

    <service android:name="com.parse.PushService" />
    <receiver android:name="com.parse.ParsePushBroadcastReceiver"
        android:exported="false">
      <intent-filter>
        <action android:name="com.parse.push.intent.RECEIVE" />
        <action android:name="com.parse.push.intent.DELETE" />
        <action android:name="com.parse.push.intent.OPEN" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.parse.GcmBroadcastReceiver"
        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" />
    
        <!--
          IMPORTANT: Change "com.parse.starter" to match your app's package name.
        -->
        <category android:name="com.parse.starter" />
      </intent-filter>
    </receiver>
    


  • 通常马上开幕前添加像快速指南说明权限&lt;应用&GT; 标记,并等同于你的,也提到包名:

  • add permissions like the quick guide instructions typically immediately before the opening <application> tag, and make the mentioned package names identical to the yours, too:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    
    <!--
      IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
      to match your app's package name + ".permission.C2D_MESSAGE".
    -->
    <permission android:protectionLevel="signature"
        android:name="com.parse.starter.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.parse.starter.permission.C2D_MESSAGE" />
    


  • 最后一步) 干得好!享受推你的东西;)

    这篇关于如何注册我的Andr​​oid应用解析网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆