I’m having a strange error. I am developing an app that needs to send notifications on Android, So far so good. Install all plugins and change my config.xml to add plugins:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.entel904334" version="3.4" android-versionCode="10" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Entel MTB Challenge</name>
<description>
</description>
<author email="" href="">
</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="orientation" value="portrait"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="5000" />
<preference name="AutoHideSplashScreen" value="false" />
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
</feature>
<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
<feature name="PushPlugin" >
<param name="android-package" value="com.amazon.cordova.plugin.PushPlugin"/>
</feature>
<!--Plugin de notificaciones -->
<gap:plugin name="com.phonegap.plugins.pushplugin"/>
<access origin="*" />
<gap:plugin name="de.appplant.cordova.plugin.background-mode" version="0.6.3" />
Also add the following js code:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var pushNotification = window.plugins.pushNotification;
pushNotification.register(
successHandler,
errorHandler,
{
'senderID':'canvas-sum-866',
'ecb':'onNotificationGCM'
}
);
}
function successHandler(result){
console.log("RESULT "+result);
}
function errorHandler(error){
console.log("ERROR "+error);
}
function onNotificationGCM(e){
switch(e.event){
case ‘registered’:
if (e.regid.length > 0){
deviceRegistered(e.regid);
console.log("reg id "+e.regid);
sessionServiceToken.set(‘token_device’,e.regid);
}
break;
case 'message':
if (e.foreground){
alert('Mensaje');
}
break;
case 'error':
console.log("ERROOOOR");
break;
default:
alert("DEFAULT");
break;
}
}
All this is fine, but when running “ionic build android” Me generates another apk, with another package name and does not work. In the android manifest this this code
<application android:debuggable="true">
<receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" 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="com.ionicframework.entel904334" />
</intent-filter>
</receiver>
<service android:name="com.plugin.gcm.GCMIntentService" />
<service android:name="de.appplant.cordova.plugin.background.ForegroundService" />
<activity android:exported="true" android:launchMode="singleTop" android:name="com.plugin.gcm.PushHandlerActivity" android:screenOrientation="portrait" />
</application>
<activity android:exported="true" android:name="com.plugin.gcm.PushHandlerActivity" />
<receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" 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="com.ionicframework.entel904334" />
</intent-filter>
</receiver>
<service android:name="com.plugin.gcm.GCMIntentService" />
<service android:name="de.appplant.cordova.plugin.background.ForegroundService" />
I try to erase this code but I have not succeeded, someone knows why this error occurs? The apk is generated com.plugin.gcm.PushHandlerActivity-debug-unaligned