用户工具

站点工具


差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

en:razor:plugins:huaweipush [2015/03/19 14:01]
cobub [6.账户与结算]
en:razor:plugins:huaweipush [2017/07/14 11:18]
行 1: 行 1:
-====== HuaweiPush Plugin ====== 
  
- 
-Huawei Push the plug is Cobub Razor official platform based Huawei alliance to push the development of a plug-in. ​ 
-It integrates features a push function Tag Huawei and Cobub Razor Alliance platform provides more convenient, fast and accurate a push. 
-Huawei Union open platform for messaging applications to help companies push through low-cost Internet access, provide a sound, efficient and stable service system solves the Internet cloud to the phone side of the message interoperability problems. 
- 
-===== Integration steps: ===== 
- 
- 
-Huawei push the plug before integration,​ ensure the establishment of a database related tables, can go to[[razor:​plugins:​start|here]]sql file Download related to import into your database, create a related table (note changes in the prefix table sql razor_, in order to maintain your own database table prefix and consistent). 
- 
-** 1.**Ensure Cobub Razor and Cobub authorized users Center has successfully bound.** If not binding, see [[razor:​plugins:​start|here]]. 
- 
-**2.Activate Huawei Cobub Razor in push applications ** 
-To use the plug-in Huawei push push, the system needs to be allocated for each of the corresponding authorization Key App (currently only supports Android platform). 
- 
-**3. Huawei push SDK integration ** 
-Huawei Huawei Push Coalition downloaded SDK for the. Rar file, after local decompression,​ go to “micro-kernel SDK \ Doc” directory, “Huawei PushSDK integration instructions. Pdf” Reference Doc directory integration Huawei push SDK documentation 
- 
-Integration steps: 
- 
-==== 3.1 Integration jar package: ==== 
- 
-Adding acquired cobub razor’s ums.jar Huawei to push the project libs directory. 
-Right on the project and select Build Path-> Configure build path … -> left select Java Build Path->; choose Libraries Select Card ->; Add JARs .. ->; choose the items currently Libs directory, select the jar package, and then click OK. 
- 
-==== 3.2.Modify download Huawei push SDK project package name and package name to create an application consistent: ==== 
- 
- 
-==== 3.3 Configuration AndroidManifest.xml file. ==== 
- 
-*  Add authorization 
-<​code>​ 
-    uses-permission android:​name="​com.android.launcher.permission.INSTALL_SHORTCUT"​ 
-    uses-permission android:​name="​com.android.mylauncher.permission.INSTALL_SHORTCUT"</​code>​ 
-* Add Service Statement 
-<​code>​ 
-meta-data ​ 
-             ​android:​name="​UMS_APPKEY" ​ 
-             ​android:​value="​APPKEY"​ 
-meta-data 
-</​code>​ 
-Note: PACKAGENAME replace the package name for the project. 
-APPKEY which is created by Cobub razor to get to the application of  
- 
-==== 3.4 Add SendMapping.java mapping file: SendMapping.java document on ‘.. \ src \ project name’ directory ==== 
- 
-<​code>​ 
-package ​ PACKAGENAME;​ 
-import android.content.BroadcastReceiver;​ 
-import android.content.Context;​ 
-import android.content.Intent;​ 
-import android.content.SharedPreferences;​ 
-import android.util.Log;​ 
-import org.apache.http.HttpResponse;​ 
-import org.apache.http.client.HttpClient;​ 
-import org.apache.http.client.methods.HttpPost;​ 
-import org.apache.http.entity.StringEntity;​ 
-import org.apache.http.impl.client.DefaultHttpClient;​ 
-import org.apache.http.protocol.HTTP;​ 
-import org.apache.http.util.EntityUtils;​ 
-import org.json.JSONException;​ 
-import org.json.JSONObject;​ 
-import com.wbtech.ums.UmsAgent;​ 
-import com.wbtech.ums.common.CommonUtil;​ 
-import java.io.UnsupportedEncodingException;​ 
-import java.net.URLDecoder;​ 
- 
-public class SendMapping extends BroadcastReceiver { 
-    public static String NAME = "​BroadcastReceiver2SendMapping";​ 
-    boolean isGetCobubBroadcoast = false; 
-    boolean isGetHuaWeiBroadcoast = false; 
-    String serviceURL = "​http://​push.cobub.com/​index.php?/​api/​huawei/​postmapping";​ 
- 
-    public SendMapping() { 
-    } 
-    @Override 
-    public void onReceive(Context context, Intent intent) { 
-        // TODO Auto-generated method stub 
-        Log.d(NAME,"​SendMapping onReceive"​);​ 
-//注册 receiver 
-//        SendMapping receiver = new SendMapping();​ 
-//        IntentFilter filter = new IntentFilter();​ 
-//        filter.addAction("​cobub.razor.message"​);​ 
-//        filter.addAction("​com.huawei.android.push.intent.REGISTRATION"​);​ 
-//        registerReceiver(receiver,​ filter); 
-        String action = intent.getAction();​ 
-        SharedPreferences sp= context.getSharedPreferences("​cobub_huawei_sharepreference",​ 0); 
-        if(action.equals("​cobub.razor.message"​)){ 
-            String deviceid = intent.getStringExtra("​deviceid"​);​ 
-            Log.d("​postdata ", "get deviceid ​  : "​+deviceid);​ 
-            sp.edit().putString("​deviceid",​ deviceid).commit();​ 
-            isGetCobubBroadcoast = true; 
-        } 
-        if(action.equals("​com.huawei.android.push.intent.REGISTRATION"​)){ 
-            String deviceToken;​ 
-            try { 
-                deviceToken = new String(intent.getByteArrayExtra("​device_token"​),​ "​UTF-8"​);​ 
-                sp.edit().putString("​deviceToken",​ deviceToken).commit();​ 
-                Log.d("​postdata ", "get deviceToken ​  : "​+deviceToken);​ 
-                isGetHuaWeiBroadcoast = true; 
-            } catch (UnsupportedEncodingException e) { 
-                // TODO Auto-generated catch block 
-                e.printStackTrace();​ 
-            } 
- 
-        } 
-        if(isGetCobubBroadcoast&&​ isGetHuaWeiBroadcoast){ 
-            final JSONObject obj = new JSONObject();​ 
-            String deviceid = sp.getString("​deviceid",​ ""​);​ 
-            String deviceToken = sp.getString("​deviceToken",​ ""​);​ 
-            try { 
-                obj.put("​deviceToken",​ deviceToken);​ 
-                obj.put("​deviceid",​ deviceid); 
-                obj.put("​app_key",​ CommonUtil.getAppKey(context));​ 
-            } catch (JSONException e) { 
-                // TODO Auto-generated catch block 
-                e.printStackTrace();​ 
-            } 
- 
-            Log.d("​postdata ", "post deviceid and deviceToken"​);​ 
-            new Thread(new Runnable() { 
- 
- @Override 
- public void run() { 
- // TODO Auto-generated method stub 
- post(serviceURL,​obj.toString());​ 
- isGetCobubBroadcoast = false; 
- isGetHuaWeiBroadcoast = false; 
- } 
- }).start();​ 
-        } 
-    } 
-    public static int post(String url, String data) { 
-        String returnContent = "";​ 
-        HttpClient httpclient = new DefaultHttpClient();​ 
-        HttpPost httppost = new HttpPost(url);​ 
-        Log.d("​postdata",​ "​SMpost"​+url+" ​ "​+data);​ 
-        try { 
-            StringEntity se = new StringEntity("​content="​+data,​ HTTP.UTF_8);​ 
-            se.setContentType("​application/​x-www-form-urlencoded"​);​ 
-            httppost.setEntity(se);​ 
-            HttpResponse response = httpclient.execute(httppost);​ 
-            int status = response.getStatusLine().getStatusCode();​ 
-            Log.d("​postdata ", "​status==="​+status);​ 
-            String returnXML = EntityUtils.toString(response.getEntity());​ 
-            returnContent = URLDecoder.decode(returnXML);​ 
-            switch (status) { 
-            case 200: 
-            { 
-            Log.d("​postdata ", "​status===200"​);​ 
-                JSONObject obj = new JSONObject(returnContent);​ 
-                return obj.getInt("​flag"​);​ 
-            }  
-              default: 
-              Log.d("​postdata ", "​status="​+status);​ 
-                break; 
-            } 
-        } catch (Exception e) {  
-        e.printStackTrace();​ 
-            JSONObject jsonObject = new JSONObject();​ 
-                try { 
-                    jsonObject.put("​err",​ e.toString());​ 
-                    returnContent = jsonObject.toString();​ 
-                } catch (JSONException e1) { 
-                    e1.printStackTrace();​ 
-                } 
-        } 
-        Log.d("​postdata ", "post deviceid error deviceToken"​);​ 
-        return 0; 
-    }  
-} 
-</​code>​ 
-==== 3.5 Initialize SDK ==== 
- 
-Import UmsAgent in your application’s main Activity Lane; 
-<​code>​ 
-import com.wbtech.ums.UmsAgent;</​code>​ 
-Then start the initialization phase in your application initialization SDK: 
-<​code>​ 
-UmsAgent.setBaseURL("​http://​192.168.1.104:​80/​dev07/​razor/​web/​index.php?"​);​ 
- UmsAgent.update(this);​ 
- UmsAgent.onError(this);​ 
- UmsAgent.setDefaultReportPolicy(this,​ 1); 
- UmsAgent.bindUserIdentifier(this,​ "​xd.."​);​ 
- UmsAgent.postClientData(this);​ 
- 
- //注册 receiver 
-       SendMapping receiver = new SendMapping();​ 
-       IntentFilter filter = new IntentFilter();​ 
-       filter.addAction("​cobub.razor.message"​);​ 
-       filter.addAction("​com.huawei.android.push.intent.REGISTRATION"​);​ 
-       registerReceiver(receiver,​ filter); 
-</​code>​ 
-This method must be called within the Activity or Service category. Under normal circumstances,​ you can call the Activity’s onCreate () method 
-To ensure that unforeseen circumstances cause initialization fails, the application is recommended once every start calling the initialization interface.。 
- 
-===== 4 Use Huawei’s push service ===== 
- 
-Huawei’s push into Cobub Razor Plug-home, plug-in application reads a list of all current system Android. 
-Has a push operation after each application,​ the user can select the message type according to their needs. 
-Push into the detailed interface, select the label as required or the entire APP push, and push relevant content to fill 
- 
-===== 5 View a pushing and send reports ​ ===== 
- 
-Push into the plug-in reporting module, the user can view the user push reports. Note: The system supports only 30 days to push the report query service. The user can select the time period through the upper right corner. 
-Push the report shows all active push APP report, click the report to push a single APP view a single application. 
- 
-===== 6 account and balance sheet  ===== 
- 
-Huawei push the plug on a monthly basis, based on the total number of users the system last month, every month all users APP online users to be settled. 
-Huawei push the plug is charged according to the number of online settlement of the month, regardless of the number of push. 
-In order to ensure the normal push service, please recharge module pre individuals Center account recharge. 
- 
-===== 7.常见问题 ===== 
- 
-如何获取Package Name? 
-应用标识(Package Name),常以com开头 
-方法: 
-  * 手机上打开你的应用 
-  * 点击设置 ->; 应用程序 ->; 管理应用程序 ->; 正在运行,在列表中找到你的程序 
-  * 在进程中可以看到应用的应用标识(Package Name) 
en/razor/plugins/huaweipush.txt · 最后更改: 2017/07/14 11:18 (外部编辑)