友盟消息推送初试

  注册与下载sdk略过,直接贴代码

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.monta.paopao"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />
    <!-- 去掉READ_LOGS权限-->
    <uses-permission android:name="android.permission.READ_LOGS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <!--开机启动添加 -->
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.monta.paopao.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.monta.paopao.TestActivity" />    <!-- 测试用,可删除 -->
         <activity android:name="com.monta.paopao.TwoActivity" />
        <receiver
            android:name="com.umeng.message.NotificationProxyBroadcastReceiver"
            android:exported="false" >
        </receiver>
        <receiver android:name="com.umeng.message.RegistrationReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REMOVED" />

                <data android:scheme="package" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.umeng.message.UmengBroadcastReceiver" >
            <intent-filter>
                <action android:name="org.agoo.android.intent.action.RECEIVE" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.monta.paopao.intent.action.COMMAND" />
            </intent-filter>
            <intent-filter>
                <action android:name="org.agoo.android.intent.action.RE_ELECTION_V2" />
            </intent-filter>
        </receiver>

        <service
            android:name="com.umeng.message.UmengService"
            android:exported="true"
            android:process=":umengService_v1" >
            <intent-filter>
                <action android:name="com.monta.paopao.intent.action.START" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.monta.paopao.intent.action.COCKROACH" />
            </intent-filter>
            <intent-filter>
                <action android:name="org.agoo.android.intent.action.PING" />
            </intent-filter>
        </service>
        <service
            android:name="org.android.agoo.service.ElectionService"
            android:exported="true"
            android:process=":umengService_v1" >
            <intent-filter>
                <action android:name="org.agoo.android.intent.action.ELECTION_V2" />
            </intent-filter>
        </service>
        <service android:name="com.umeng.message.UmengIntentService" />

        <meta-data
            android:name="UMENG_APPKEY"
            android:value="****" >
        </meta-data>
        <meta-data
            android:name="UMENG_MESSAGE_SECRET"
            android:value="*******" >
        </meta-data>
        <meta-data
            android:name="UMENG_CHANNEL"
            android:value="Umeng" >
        </meta-data>

        <!-- If you donot want to use the standard notification bar in SDK, you can define IntentService instead to handle message. -->
 <!-- 自定义消息接收service -->        <service android:name="com.monta.paopao.MyPushIntentService" />
        <service android:name="com.umeng.message.UmengDownloadResourceService" >

        </service>

  <!-- startReceiver 用来设置开机启动 消息推送的接收service -->

   <receiver android:name="com.monta.paopao.StartReceiver">
             <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED"></action>
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </receiver>
    </application>

其中com.monta.paopao 为推送应用包名。

接下来是自定义的 application

package com.monta.paopao;

import android.app.Application;
import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.Toast;

import com.monta.paopao.R;
import com.umeng.message.PushAgent;
import com.umeng.message.UTrack;
import com.umeng.message.UmengMessageHandler;
import com.umeng.message.UmengNotificationClickHandler;
import com.umeng.message.UmengRegistrar;
import com.umeng.message.entity.UMessage;

public class MyApplication extends Application {
    private static final String TAG = MyApplication.class.getName();

    private PushAgent mPushAgent;

    @Override
    public void onCreate() {
        mPushAgent = PushAgent.getInstance(this);
        mPushAgent.setDebugMode(true);

        /**
         * 该Handler是在IntentService中被调用,故
         * 1. 如果需启动Activity,需添加Intent.FLAG_ACTIVITY_NEW_TASK
         * 2. IntentService里的onHandleIntent方法是并不处于主线程中,因此,如果需调用到主线程,需如下所示;
         *           或者可以直接启动Service
         * */
        UmengMessageHandler messageHandler = new UmengMessageHandler(){
            @Override
            public void dealWithCustomMessage(final Context context, final UMessage msg) {

                new Handler(getMainLooper()).post(new Runnable() {

                    @Override
                    public void run() {
                        UTrack.getInstance(getApplicationContext()).trackMsgClick(msg);
                        Toast.makeText(context, msg.custom, Toast.LENGTH_LONG).show();

                    }
                });
            }

            @Override
            public Notification getNotification(Context context,
                    UMessage msg) {
                switch (msg.builder_id) {
                case 1:
                    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
                    RemoteViews myNotificationView = new RemoteViews(context.getPackageName(), R.layout.notification_view);
                    myNotificationView.setTextViewText(R.id.notification_title, msg.title);
                    myNotificationView.setTextViewText(R.id.notification_text, msg.text);
                    myNotificationView.setImageViewBitmap(R.id.notification_large_icon, getLargeIcon(context, msg));
                    myNotificationView.setImageViewResource(R.id.notification_small_icon, getSmallIconId(context, msg));
                    builder.setContent(myNotificationView);
                    builder.setAutoCancel(true);
                    Notification mNotification = builder.build();
                    //由于Android v4包的bug,在2.3及以下系统,Builder创建出来的Notification,并没有设置RemoteView,故需要添加此代码
                    mNotification.contentView = myNotificationView;
                    return mNotification;
                default:
                    //默认为0,若填写的builder_id并不存在,也使用默认。
                    return super.getNotification(context, msg);
                }
            }
        };
        mPushAgent.setMessageHandler(messageHandler);

        /**
         * 该Handler是在BroadcastReceiver中被调用,故
         * 如果需启动Activity,需添加Intent.FLAG_ACTIVITY_NEW_TASK
         * */
        UmengNotificationClickHandler notificationClickHandler = new UmengNotificationClickHandler(){
            @Override
            public void dealWithCustomAction(Context context, UMessage msg) {
                Toast.makeText(context, msg.custom, Toast.LENGTH_LONG).show();
            }
        };
        mPushAgent.setNotificationClickHandler(notificationClickHandler);
        String device_token = UmengRegistrar.getRegistrationId(this);
        Log.i("device_token", device_token);

    }

}

完全照搬推送demo中的application

接下来是重头戏 mainActivity

/**
 * Copyright (C) 2013 Umeng, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.monta.paopao;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Notification;
import android.app.ProgressDialog;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.NotificationCompat;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RemoteViews;
import android.widget.TextView;
import android.widget.Toast;

import com.monta.paopao.R;
import com.umeng.message.ALIAS_TYPE;
import com.umeng.message.IUmengRegisterCallback;
import com.umeng.message.IUmengUnregisterCallback;
import com.umeng.message.PushAgent;
import com.umeng.message.UTrack;
import com.umeng.message.UmengMessageHandler;
import com.umeng.message.UmengNotificationClickHandler;
import com.umeng.message.UmengRegistrar;
import com.umeng.message.entity.UMessage;
import com.umeng.message.tag.TagManager;

public class MainActivity extends Activity {
    protected static final String TAG = MainActivity.class.getSimpleName();

    //------------设置标签等控件,demo中有,暂时先不考虑------------//
    private EditText edTag, edAlias;
    private TextView tvStatus, infoTextView;
    private ImageView btnEnable;
    private Button btnaAddTag, btnListTag, btnAddAlias;
    private ProgressDialog dialog;
    //------------设置标签等控件,demo中有,暂时先不考虑------------//

    private PushAgent mPushAgent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        printKeyValue();

        mPushAgent = PushAgent.getInstance(this);
        mPushAgent.onAppStart();
        mPushAgent.enable(mRegisterCallback);

        //------------设置标签等控件,demo中有,暂时先不考虑------------//
        tvStatus = (TextView) findViewById(R.id.tvStatus);
        btnEnable = (ImageView) findViewById(R.id.btnEnable);
        btnaAddTag = (Button) findViewById(R.id.btnAddTags);
        btnAddAlias = (Button) findViewById(R.id.btnAddAlias);
        btnListTag = (Button) findViewById(R.id.btnListTags);
        infoTextView = (TextView)findViewById(R.id.info);
        edTag = (EditText) findViewById(R.id.edTag);
        edAlias = (EditText) findViewById(R.id.edAlias);

        tvStatus.setOnClickListener(clickListener);
        btnEnable.setOnClickListener(clickListener);
        btnaAddTag.setOnClickListener(clickListener);
        btnListTag.setOnClickListener(clickListener);
        btnAddAlias.setOnClickListener(clickListener);

        updateStatus();
        //------------设置标签等控件,demo中有,暂时先不考虑------------//

        //------------重点!!! 以下两行设置通过myPushIntentService来处理推送来的消息,其他代码块暂时不做处理------------//
        mPushAgent.setPushIntentServiceClass(MyPushIntentService.class);
        mPushAgent.getMessageHandler();
    }

    @Override
    protected void onDestroy() {
        Log.d("-------------------------", "onDestroy");
        super.onDestroy();
    }

    private void printKeyValue() {
        //获取自定义参数
        Bundle bun = getIntent().getExtras();
        if (bun != null)
        {
            Set<String> keySet = bun.keySet();
            for (String key : keySet) {
                String value = bun.getString(key);
                Log.i(TAG, key + ":" + value);
            }
        }

    }

    private void switchPush(){
        String info = String.format("enabled:%s  isRegistered:%s",
                mPushAgent.isEnabled(), mPushAgent.isRegistered());
        Log.i(TAG, "switch Push:" + info);

        btnEnable.setClickable(false);
        if (mPushAgent.isEnabled() || UmengRegistrar.isRegistered(MainActivity.this)) {
            mPushAgent.disable(mUnregisterCallback);
        } else {
            mPushAgent.enable(mRegisterCallback);
        }
    }

    private void updateStatus() {
        String pkgName = getApplicationContext().getPackageName();
        String info = String.format("enabled:%s  isRegistered:%s  DeviceToken:%s",
                mPushAgent.isEnabled(), mPushAgent.isRegistered(),
                mPushAgent.getRegistrationId());
        tvStatus.setText("应用包名:"+pkgName+"\n"+info);

        btnEnable.setImageResource(mPushAgent.isEnabled()?R.drawable.open_button:R.drawable.close_button);
        btnEnable.setClickable(true);
        copyToClipBoard();

        Log.i(TAG, "updateStatus:" + String.format("enabled:%s  isRegistered:%s",
                mPushAgent.isEnabled(), mPushAgent.isRegistered()));
        Log.i(TAG, "=============================");
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    @SuppressLint("NewApi")
    @SuppressWarnings("deprecation")
    private void copyToClipBoard()
    {
        if (Build.VERSION.SDK_INT<11)
            return;
        String deviceToken = mPushAgent.getRegistrationId();
        if (!TextUtils.isEmpty(deviceToken))
        {
            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            clipboard.setText(deviceToken);
            toast("DeviceToken已经复制到剪贴板了");
        }
    }

    // sample code to add tags for the device / user
    private void addTag() {
        String tag = edTag.getText().toString();
        if (TextUtils.isEmpty(tag))
        {
            toast("请先输入Tag");
            return;
        }
        if (!mPushAgent.isRegistered())
        {
            toast("抱歉,还未注册");
            return;
        }

        showLoading();
        new AddTagTask(tag).execute();
        hideInputKeyboard();
    }

    // sample code to add tags for the device / user
    private void listTags() {
        if (!mPushAgent.isRegistered())
        {
            toast("抱歉,还未注册");
            return;
        }
        showLoading();
        new ListTagTask().execute();
    }

    // sample code to add alias for the device / user
    private void addAlias() {
        String alias = edAlias.getText().toString();
        if (TextUtils.isEmpty(alias))
        {
            toast("请先输入Alias");
            return;
        }
        if (!mPushAgent.isRegistered())
        {
            toast("抱歉,还未注册");
            return;
        }
        showLoading();
        new AddAliasTask(alias).execute();
        hideInputKeyboard();
    }

    public void showLoading(){
        if (dialog == null){
            dialog = new ProgressDialog(this);
            dialog.setMessage("Loading");
        }
        dialog.show();
    }

    public void updateInfo(String info){
        if (dialog != null && dialog.isShowing())
            dialog.dismiss();
        infoTextView.setText(info);
    }

    public OnClickListener clickListener  = new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (v == btnaAddTag){
                addTag();
            }else if (v == btnAddAlias){
                addAlias();
            }else if (v == btnListTag){
                Intent intent = new Intent(getApplicationContext(), TwoActivity.class);
                startActivity(intent);
                finish();
//                listTags();
            }else if (v == btnEnable){
                switchPush();
            }else if (v == tvStatus) {
                updateStatus();
            }
        }
    };

    public Handler handler = new Handler();
    public IUmengRegisterCallback mRegisterCallback = new IUmengRegisterCallback() {

        @Override
        public void onRegistered(String registrationId) {
            // TODO Auto-generated method stub
            handler.post(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    updateStatus();
                }
            });
        }
    };

    public IUmengUnregisterCallback mUnregisterCallback = new IUmengUnregisterCallback() {

        @Override
        public void onUnregistered(String registrationId) {
            // TODO Auto-generated method stub
            handler.post(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    updateStatus();
                }
            });
        }
    };

    private Toast mToast;
    public void toast(String str){
        if (mToast == null)
            mToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
        mToast.setText(str);
        mToast.show();
    }

    class AddTagTask extends AsyncTask<Void, Void, String>{

        String tagString;
        String[] tags;
        public AddTagTask(String tag) {
            // TODO Auto-generated constructor stub
            tagString = tag;
            tags = tagString.split(",");
        }

        @Override
        protected String doInBackground(Void... params) {
            // TODO Auto-generated method stub
            try {
                TagManager.Result result = mPushAgent.getTagManager().add(tags);
                Log.d(TAG, result.toString());
                return result.toString();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPostExecute(String result) {
            edTag.setText("");
            updateInfo("Add Tag:\n" + result);
        }
    }

    class AddAliasTask extends AsyncTask<Void, Void, Boolean>{

        String alias;

        public AddAliasTask(String aliasString) {
            // TODO Auto-generated constructor stub
            this.alias = aliasString;
        }

        protected Boolean doInBackground(Void... params) {
            try {
                return mPushAgent.addAlias(alias, ALIAS_TYPE.SINA_WEIBO);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return false;
        }

        @Override
        protected void onPostExecute(Boolean result) {
            if (Boolean.TRUE.equals(result))
                Log.i(TAG, "alias was set successfully.");

            edAlias.setText("");
            updateInfo("Add Alias:" + (result?"Success":"Fail"));
        }

    }

    class ListTagTask extends AsyncTask<Void , Void, List<String>>{
        @Override
        protected List<String> doInBackground(Void... params) {
            List<String> tags = new ArrayList<String>();
            try {
                tags = mPushAgent.getTagManager().list();
                Log.d(TAG, String.format("list tags: %s", TextUtils.join(",", tags)));
            } catch (Exception e) {
                e.printStackTrace();
            }
            return tags;
        }

        @Override
        protected void onPostExecute(List<String> result) {
            if (result != null) {
                StringBuilder info = new StringBuilder();
                info.append("Tags:\n");
                for (int i=0; i<result.size(); i++){
                    String tag = result.get(i);
                    info.append(tag+"\n");
                }
                info.append("\n");
                updateInfo(info.toString());
            }
            updateInfo("");
        }
    }

    public void hideInputKeyboard()
    {
        ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
        .hideSoftInputFromWindow(getCurrentFocus()
        .getWindowToken(),
        InputMethodManager.HIDE_NOT_ALWAYS);
    }
}

接下来是自定义的service ,用于接收处理推送来的消息。

package com.monta.paopao;

import org.android.agoo.client.BaseConstants;
import org.json.JSONObject;

import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.widget.RemoteViews;

import com.umeng.common.message.Log;
import com.umeng.message.UmengBaseIntentService;
import com.umeng.message.entity.UMessage;

/**
 * Developer defined push intent service.
 * Remember to call {@link com.umeng.message.PushAgent#setPushIntentServiceClass(Class)}.
 * @author lucas
 *
 */
public class MyPushIntentService extends UmengBaseIntentService{
    private static final String TAG = MyPushIntentService.class.getName();

    @Override
    protected void onMessage(Context context, Intent intent) {
        Log.d("onMessage", "onMessageonMessageonMessageonMessageonMessageonMessageonMessageonMessage");
        super.onMessage(context, intent);
        try {
            String message = intent.getStringExtra(BaseConstants.MESSAGE_BODY);
            UMessage msg = new UMessage(new JSONObject(message));
            android.util.Log.d(TAG, "-----------------------------");
            Log.d(TAG, "message="+"----------------------------------");
            Log.d(TAG, "message="+message);
            Log.d(TAG, "custom="+msg.custom);
            Log.d(TAG, "message="+"----------------------------------");
            android.util.Log.d(TAG, "-----------------------------");
        } catch (Exception e) {
            Log.e(TAG, e.getMessage());
        }
    }
}

经过测试,服务器推送来的消息可以通过这个MyPushIntentService  onMessage方法中接收到,弹出消息框等问题待下一步进行处理。

接下来就是最后一步,设置开机启动推送接收服务MyPushIntentService ,通过广播接收者StartReceiver实现:

package com.monta.paopao;

import com.umeng.message.PushAgent;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class StartReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i("--------------------", "开机启动楼~~~~");
        PushAgent mPushAgent = PushAgent.getInstance(context);
        mPushAgent.onAppStart();
        mPushAgent.setPushIntentServiceClass(MyPushIntentService.class);
        mPushAgent.getMessageHandler();
    }

}

资源文档等仍为原demo,至此基本的android推送自定义接收处理完成,更深入的处理学习理解完成后再贴出code。

时间: 2024-10-09 20:24:31

友盟消息推送初试的相关文章

友盟消息推送

博主也是第一次使用友盟消息推送,其中的配置我也不需要多讲,在这里附上iOS客户端友盟消息推送的集成文档,并讲讲个人使用心得 iOS友盟消息推送集成文档 这里既有集成文档的讲解步骤,还有证书配置的指南,只需要按照步骤集成即可. 1.配置服务器地址 友盟消息推送后台:适配iOS9,在info.plist文件中按截图配置 以iOS9 SDK编译的工程会默认以SSL安全协议进行网络传输,即HTTPS,如果依然使用HTTP协议请求网络会报系统异常并中断请求.目前可用如下两种方式保持用HTTP进行网络连接:

.NET手记-友盟消息推送服务器端加密算法的实现

最近为App开发消息推送功能,这里我们采用了友盟的消息推送服务,但其后台简陋,可定制化程度低,所以决定接入服务器端API,在自己的服务器上部署一套推送服务. 其中涉及到很多问题,首先要解决的就是与友盟服务器的加密验证问题. 官方示例 友盟官方的加密算法使用Python实现的,核心是MD5算法,如下: import hashlib import json def md5(s): print s m = hashlib.md5(s) return m.hexdigest() appkey = '你的

友盟消息推送新版 SDK 为什么要支持多包名推送?

友盟消息推送 Android SDK 升级至 v 1.4.1 版本了!那问题来了,v 1.4.1 版本有什么新功能呢? “支持多包名推送”!新版 SDK 下载地址 开发者都知道,对于各种 Android 应用,特别是 Android 游戏而言,针对不同的渠道定制版本.使用不同的包名是运营中常见的一环,但是这样会导致后续使用消息推送时工作量过大,每个包都要单独推送,费时费力,还难以做到精准推送,效率低下……在不改变使用多包名的现状下,该如何提升消息推送效率? 友盟消息推送团队新推出的“多包名推送”

友盟消息推送安卓文档、 python端sdk、demo代码

一,友盟消息推送python服务端sdk地址和文档地址 1.sdk地址:http://dev.umeng.com/system/resources/W1siZiIsIjIwMTYvMDgvMTkvMTdfNDFfMzhfNzg2X3B1c2hfc2VydmVyX3B5c2RrLnppcCJdXQ/push-server-pysdk.zip 2.文档:http://dev.umeng.com/push/android/api-doc 二.python官方sdk代码中的错误(没错!官方代码有错.)

thinkphp整合系列之友盟消息推送

上篇文章 thinkphp集成系列之phpmailer批量发送邮件讲过的: 邮件有着零成本.内容丰富的优点: 但是一个非常硬的硬伤:这家伙的及时性太差了: 尤其是随着90.00后的崛起:从上网开始体验的就是QQ.微信的即时通讯: 唯一有的邮箱也还是自动开通的QQ邮箱:然而还是一连串的未读: 那么有木有一种零成本.但是及时性比较好的方案呢? 有的:那就是消息推送:当然:前提是用户已经安装了app: 今个先就友盟的推送来讲解下:http://push.umeng.com/ 依然是以开源项目示例:ht

【转载自友盟消息推送iOS文档】在appDelegate中注册推送

1.2   基本功能集成指南 提示 请先在友盟的消息推送管理后台中创建App,获得AppKey和AppSecret 导入SDK 下载 UMessage_Sdk_All_x.x.x.zip并解压缩 导入插件 所需SDK文件夹:UMessage_Sdk_x.x.x 请在你的工程目录结构中,右键选择Add->Existing Files…,选择这个文件夹.或者将这个文件夹拖入XCode工程目录结构中,在弹出的界面中勾选Copy items into destination group's folder

友盟消息推送(一)

最近项目打算做推送功能,最后选择了友盟推送,集成友盟sdk,非常的方便. 第一步: 首先登陆友盟官网,注册友盟账号 然后选择消息推送模块,(因为该项目只做推送功能) 第二部: 添加应用:分ios和安卓两个应用,选择ios客户端,完善信息 完善后的信息截图如下:这一步是获取AppKey和        应用名保持和你做的项目一致. 点击提交并获取AppKey. 每个项目的AppKye是唯一的,在集成sdk时将AppKey集成到项目中,如图 接下就设置消息的推送证书,可以参考友盟的证书设置指南非常的

友盟消息推送UPush

第一步:把下载的SDK里面的PushSDK当做Module导入自己的项目 第二步:在自己项目的build.gradle里面一定要配置applicationId defaultConfig { applicationId "应用的包名" minSdkVersion 8 targetSdkVersion 22 } 第三步:在主module的build.gradle文件的dependencies下添加compile project(':PushSDK'). ompile project(':

友盟消息推送和更新XML配置

1 <receiver 2 android:name="com.umeng.message.NotificationProxyBroadcastReceiver" 3 android:exported="false" > 4 </receiver> 5 6 <receiver 7 android:name="com.umeng.message.RegistrationReceiver" > 8 <inte