這里會(huì)顯示出您選擇的修訂版和當(dāng)前版本之間的差別。
兩側(cè)同時(shí)換到之前的修訂記錄 前一修訂版 后一修訂版 | 前一修訂版 | ||
en:razor:plugins:gcm [2015/03/19 11:27] cobub [2. Obtain an authorization code and get authorization in authorization module of Cobub Razor.] |
en:razor:plugins:gcm [2017/07/14 11:18] (當(dāng)前版本) |
||
---|---|---|---|
行 1: | 行 1: | ||
+ | ~~Title:Cobub Razor GCM Plugin - Mobile Apps Marketing Platform of Open Source - Mobile Analytics & Mobile Push Notification Solutions - Cobub Mobile Developer Center~~ | ||
+ | {{description>Cobub Razor is an Open Source Mobile Analytics. It integrates the push function of GCM and the Tag function of Cobub Razor , and make you push messages more conveniently, fastly and accurately.}} | ||
+ | {{keywords>Cobub Razor,open source mobile analytics,mobile analytics,mobile app analytics, gcm, plugin}} | ||
+ | |||
====== GCM Plugin ====== | ====== GCM Plugin ====== | ||
===== GCM plug-in is a push plug-in that Cobub Razor developed which based on GCM . ===== | ===== GCM plug-in is a push plug-in that Cobub Razor developed which based on GCM . ===== | ||
行 15: | 行 19: | ||
[[#Register a Google Account, get a Project Number and API Key.|How register a Google Account to get a Project Number and Api Key]]? | [[#Register a Google Account, get a Project Number and API Key.|How register a Google Account to get a Project Number and Api Key]]? | ||
- | [[http://dev.cobub.com/users/index.php?/help/userkey#n1|How authorize a Cobub account]]? | + | [[http://www.cobub.com/users/en/index.php?/help/userkey#n1|How authorize a Cobub account]]? |
==== 1. Register an account in Cobub User Center. ==== | ==== 1. Register an account in Cobub User Center. ==== | ||
行 22: | 行 26: | ||
Users can not use the GCM push service unless they register as a formal user in Cobub User Center . | Users can not use the GCM push service unless they register as a formal user in Cobub User Center . | ||
- | If you have not registered yet,please go to [[http://dev.cobub.com/users|Cobub User Center]] and register now. | + | If you have not registered yet,please go to [[http://www.cobub.com/users|Cobub User Center]] and register now. |
==== 2. Obtain an authorization code and get authorization in authorization module of Cobub Razor. ==== | ==== 2. Obtain an authorization code and get authorization in authorization module of Cobub Razor. ==== | ||
Authorization code is the secret key for interaction between Cobub Razor and Cobub User Center, users need to authorize it in authorization module of Cobub Razor after getting it. | Authorization code is the secret key for interaction between Cobub Razor and Cobub User Center, users need to authorize it in authorization module of Cobub Razor after getting it. | ||
行 28: | 行 32: | ||
Only an authorized account can use the rich extended function and value-added services of Cobub Razor provided by Cobub User Center. | Only an authorized account can use the rich extended function and value-added services of Cobub Razor provided by Cobub User Center. | ||
- | [[http://dev.cobub.com/users/index.php?/help/userkey|Obtain the authorization code and get authorization in authorization module of Cobub Razor.]] | + | [[http://www.cobub.com/users/en/index.php?/help/userkey|Obtain the authorization code and get authorization in authorization module of Cobub Razor.]] |
==== 3. Register a Google Account, get a Project Number and API Key. ==== | ==== 3. Register a Google Account, get a Project Number and API Key. ==== | ||
+ | [[https://code.google.com/apis/console|Resgister a Google account]],get a Project Number and Api Key, Project Number is the SEND_ID we need to use when programming later. | ||
+ | a)Use the account of Google and login to https://code.google.com/apis/console , click on Services, as shown below. Open Google Cloud Messaging for Android service. | ||
+ | |||
+ | |||
+ | b)Same as above, click on Overview in the left navigation bar,we can see Project Number on the right of page body,as shown below. | ||
+ | |||
+ | |||
+ | c)Same as above, click on API Access, we can see API key, as shown below where marked red line; If you can’t see API Key, you can click on “Create new Server key…” where marked redline and create a new API key. | ||
+ | |||
+ | |||
+ | d)API key is the only certificate of push function. Please login to Cobub Razor firstly,click on the GCM in the left to enter the home page of GCM, input the API key obtained above, and click on save. | ||
==== 4. SDK Integration. ==== | ==== 4. SDK Integration. ==== | ||
+ | === Step one: Add jar packages. === | ||
- | ==== 5. View reports of GCM. ==== | ||
- | ==== 1.Register an account in Cobub User Center ==== | + | - Add the ums.jar and cobubGCM.jar to the libs directory of project.? |
+ | - Right-click on the project and select Build Path->Configure build path..—> Java Build Path—>Libraries—>Add External JARs.. —>select Libs directory of the current project, select ums.jar and cobubGCM.jar, and then click on OK. | ||
- | ==== 2.Obtain an authorization code and get authorization in authorization module of Cobub Razor ==== | + | === Step two: Configurate Androidmanifet.xml file. === |
- | ==== 3.Register a Google Account, get a Project Number and Api Key ==== | ||
- | ==== 4 SDK Integration ==== | + | * Add permissions and declarations for services.? |
+ | ? | ||
+ | <code xml>? | ||
+ | ? | ||
+ | <permission? | ||
+ | android:name="PACKAGENAME.permission.C2D_MESSAGE"? | ||
+ | android:protectionLevel="signature" /> ? | ||
+ | <uses-permission android:name="PACKAGENAME.permission.C2D_MESSAGE" /> ? | ||
+ | <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> ? | ||
+ | <uses-permission android:name="android.permission.INTERNET" /> ? | ||
+ | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> ? | ||
+ | <!-- Keeps the processor from sleeping when a message is received. --> ? | ||
+ | <uses-permission android:name="android.permission.WAKE_LOCK" /> ? | ||
+ | <uses-permission android:name="android.permission.READ_PHONE_STATE"/> ? | ||
+ | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> ? | ||
+ | ? | ||
+ | </code>? | ||
+ | * Add the following content under the application tag? | ||
+ | ? | ||
+ | <code xml>? | ||
+ | <receiver? | ||
+ | android:name="com.google.android.gcm.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" /> ? | ||
+ | <category android:name="PACKAGENAME" /> ? | ||
+ | </intent-filter> ? | ||
+ | </receiver> ? | ||
+ | <receiver ? | ||
+ | android:name="com.cobub.gcm.CobubBroadcastReceiver" > ? | ||
+ | <intent-filter > ? | ||
+ | <action android:name="cobub.razor.message"/>? | ||
+ | </intent-filter> ? | ||
+ | </receiver> ? | ||
+ | <service android:name="com.cobub.gcm.GCMIntentService" /> ? | ||
+ | <meta-data android:name="UMS_APPKEY" android:value="從cobub獲取到的UMS_APPKEY"/>? | ||
+ | </code>? | ||
+ | ? | ||
+ | === Step three: Initialization for cobubGCM.jar. Generally,you can call it in the OnCreate() method of Activity. ===? | ||
+ | ? | ||
+ | ? | ||
+ | 1.Call the RazorGCM.checkDeviceAndMainfest(this) before setContentView.? | ||
+ | ? | ||
+ | 2.Set the SendID? | ||
+ | RazorGCM.setSendID(String sendid);? | ||
+ | Note: the sendid is the Project Nomber ,shown in the first figure.? | ||
+ | ? | ||
+ | 3.Call RazorGCM.register(this)? | ||
+ | ? | ||
+ | To prevent accidents from causing initialization failed, it is suggested that the application calls this interface one time when starting for every time.? | ||
+ | ==== 5. View reports of GCM. ====? | ||
+ | Push reports contains all of the Apps’ reports, click on a specific APP to view the push reports of this application.? | ||
- | ==== 5.View reports of GCM ==== | ||