摘要:
上线的APP成功集成了友盟消息推送功能,业务需要将APP拆分成商家版和市民版,商家版更换新包名,原有功能保持不变,为了保证友盟的推送功能可以正常使用,需要完成三个步骤:
1、登录友盟官网,进度消息推送界面,click here,添加新的应用,填写新包名,使用包名的AppKey、Message Secret替换旧版本的
- <meta-data
- android:name="UMENG_APPKEY"
- android:value="新包名APPKEY" >
- </meta-data>
- <meta-data
- android:name="UMENG_MESSAGE_SECRET"
- android:value="新包名MESSAGESECRET" >
- </meta-data>
- <meta-data
- android:name="UMENG_CHANNEL"
- android:value="sinolvc" >
- </meta-data>
2、Eclipse更新包名,打开AndroidManifest.xml文件,可以不用修改旧版本目录结构。关于目录结构和包名的关系,TeachCourse认为它们是两者不同的概念,在《Android Studio如何快速更改目录结构和包名?》说明两者的关系。如果使用Android Studio开发,包名是指build.gradle文件applicationId属性值。
3、旧版本使用Eclipse开发,打开AndroidManifest.xml,找到与友盟相关的组件,需要替换新包名的组件有:
(1)com.umeng.message.RegistrationReceiver,修改action字符串
- <receiver
- android:name="com.umeng.message.RegistrationReceiver"
- android:exported="false" >
- <intent-filter>
- <action android:name="新包名.intent.action.COMMAND" />
- </intent-filter>
- </receiver>
(2)com.umeng.message.UmengService,修改action字符串
- <service
- android:name="com.umeng.message.UmengService"
- android:exported="true"
- android:label="PushService"
- android:process=":push" >
- <intent-filter>
- <action android:name="新包名.intent.action.START" />
- </intent-filter>
- <intent-filter>
- <action android:name="新包名.intent.action.COCKROACH" />
- </intent-filter>
- <intent-filter>
- <action android:name="org.agoo.android.intent.action.PING_V4" />
- <category android:name="umeng" />
- </intent-filter>
- </service>
更换新包名后的商家版,解决获取不到deviceToken的问题,同时正常接收友盟推送的消息。
你可能感兴趣的文章
来源:TeachCourse,
每周一次,深入学习Android教程,关注(QQ158#9359$239或公众号TeachCourse)
转载请注明出处: https://www.teachcourse.cn/2170.html ,谢谢支持!
转载请注明出处: https://www.teachcourse.cn/2170.html ,谢谢支持!