Pushes blocked from Urbanairship after two pages navigation - push-notification

I am working with Urbanairship services for push notification.
Before entering into the query I would like to show my app manifest file for reference.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
debuggable="true"
package="package_name"
android:versionCode="9"
android:versionName="1.3.4" >
<uses-sdk
android:maxSdkVersion="19"
android:minSdkVersion="11" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:xlargeScreens="true" >
</supports-screens>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- below permission added for mixpanel api -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<!-- for cloud to device messaging -->
<permission
android:name="package_name.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="package_name.permission.C2D_MESSAGE" />
<!-- Required for the Urban Airship library -->
<permission
android:name="package_name.permission.UA_DATA"
android:protectionLevel="signature" />
<uses-permission android:name="package_name.permission.UA_DATA" />
<!-- Required for Push -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<!-- GCM requires a Google account. -->
<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.RECEIVE_WAP_PUSH" />
<!-- This app has permission to register with GCM and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="package_name.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="package_name.permission.C2D_MESSAGE" />
<!-- Required only for location -->
<!-- Use ACCESS_COARSE_LOCATION if GPS access is not necessary -->
<!-- uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" / -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- OPTIONAL - This permission is only necessary if your app has multiple processes -->
<!-- <uses-permission android:name="android.permission.BROADCAST_STICKY" /> -->
<application
android:name=".ShowApplication"
android:hardwareAccelerated="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:largeHeap="true" >
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<activity
android:name=".SplashActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.Holo.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".DomainActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:isScrollContainer="false"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".UploadHome"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:hardwareAccelerated="true"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".FilePickerActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name=".TempMediaPlayer"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name=".ShareSingleAsset"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name=".UploadResult"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<!--
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="package_name.SplashActivity"
/> -->
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="audio/*" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="audio/*" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
</activity>
<activity
android:name=".ThumbActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout"
android:hardwareAccelerated="true"
android:theme="#android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name=".SlideShowActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Holo.NoActionBar" >
</activity>
<activity
android:name=".PreviewActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name=".LoginActivity"
android:alwaysRetainTaskState="true"
android:isScrollContainer="true"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".ForgotPasswordActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Dialog" >
</activity>
<activity
android:name=".BecomeaMemberActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Dialog" >
</activity>
<activity
android:name=".DomainExpiredActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Translucent.NoTitleBar" >
</activity>
<activity
android:name=".MediaPlayerActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Holo.NoActionBar" >
</activity>
<activity
android:name=".ShareActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".ShareSendAgainActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name=".MenuActivity"
android:theme="#android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name=".ViewShowList"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTop"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<data
android:host="*.showontherun.com/"
android:scheme="http" />
<data
android:host="*.showonthecloud.com/"
android:scheme="http" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.ALL_APPS" />
</intent-filter>
</activity>
<activity
android:name=".ShowInfoPage"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name=".SupportActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.NoTitleBar"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name="com.iw.sotc.show.offline.ViewOfflineShows"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.NoTitleBar"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name="com.iw.sotc.show.offline.ViewOfflineThumbActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.NoTitleBar"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name="com.iw.sotc.show.offline.ViewOfflinePreviewPage"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.NoTitleBar"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name="com.iw.sotc.show.offline.SlideShowOfflineActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Holo.NoActionBar"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name="com.iw.sotc.dialog.SaveShowDialogActivity"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#android:style/Theme.Dialog"
android:windowSoftInputMode="stateVisible" >
</activity>
<activity
android:name="org.acra.CrashReportDialog"
android:excludeFromRecents="true"
android:finishOnTaskLaunch="true"
android:launchMode="singleInstance"
android:theme="#style/InfoDialog" >
</activity>
<service android:name="com.iw.sotc.show.offline.DownloadService" >
</service>
<service android:name=".DownloadActivityPreviewActivity" >
</service>
<service android:name=".MediaPlayerService" >
</service>
<service android:name=".UploadingService" >
</service>
<service android:name=".UploadLinkService" >
</service>
<activity
android:name=".UploadMedia"
android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation"
android:label="#string/title_activity_upload_media"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" >
</activity>
<activity
android:name=".MediaPlayer"
android:alwaysRetainTaskState="true"
android:label="#string/title_activity_media_player" >
</activity>
<!--
added by Karthikeyan V
for managing the mixpanel api survey
-->
<activity android:name="com.mixpanel.android.surveys.SurveyActivity" />
<meta-data
android:name="com.mixpanel.android.MPConfig.AutoCheckForSurveys"
android:value="false" />
<!-- added for cloud to Device(C2DM)Messaging service -->
<receiver
android:name="com.mixpanel.android.mpmetrics.GCMReceiver"
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="package_name" />
</intent-filter>
</receiver>
<!-- < added by siva for play the audio by streaming > -->
<activity
android:name=".AudioStream"
android:configChanges="keyboardHidden|orientation"
android:launchMode="singleTask" >
</activity>
<!-- added for mixpanel in-app notification -->
<meta-data
android:name="com.mixpanel.android.MPConfig.AutoShowMixpanelUpdates"
android:value="false" />
<!-- Required for the library -->
<provider
android:name="com.urbanairship.UrbanAirshipProvider"
android:authorities="package_name.urbanairship.provider"
android:exported="true"
android:multiprocess="true"
android:permission="package_name.permission.UA_DATA" />
<!-- Required for Push -->
<service android:name="com.urbanairship.push.PushService" />
<receiver android:name="com.urbanairship.CoreReceiver" />
<receiver
android:name="com.urbanairship.push.GCMPushReceiver"
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="package_name" />
</intent-filter>
<!-- Required for detecting when the application is upgraded so it can request a new GCM ID -->
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package_name" />
</intent-filter>
</receiver>
<!-- Required for analytics -->
<service android:name="com.urbanairship.analytics.EventService" />
<!-- Required for Rich Push -->
<service android:name="com.urbanairship.richpush.RichPushUpdateService" />
<!-- Required for Actions -->
<activity android:name="com.urbanairship.actions.ActionActivity" />
<service android:name="com.urbanairship.actions.ActionService" />
<!-- Required for Landing Page Action -->
<activity
android:name="com.urbanairship.actions.LandingPageActivity"
android:exported="false"
android:parentActivityName=".ThumbActivity" >
<!-- MODIFICATION REQUIRED set or remove the parent activity -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="package_name.ThumbActivity" />
<intent-filter>
<action android:name="com.urbanairship.actions.SHOW_LANDING_PAGE_INTENT_ACTION" />
<data android:scheme="http" />
<data android:scheme="https" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name="package_name.IntentReceiver" >
</receiver>
<activity
android:name=".YoutubeVideoPlayer"
android:label="#string/title_activity_youtube_video_player"
android:theme="#android:style/Theme.Black.NoTitleBar" >
</activity>
</application>
</manifest>
When executing my app, I can receive the APID. When trying to push from Urbanairship web account I had the problem as below.
If the app in DomainActivity means can receive push from UA web account at very first time.
Following the step 1app will move to User Login page (LoginActivity) , here too can receive pushes from UA web account.
Following the step 2 app navigate to Files page ( ThumbActivity) here I can't receive the push messages.
The UA Error console shows "Application does not have permission to send to this device
Original Message: Error: mismatched sender ID"
Note : Without changing the sender ID the steps 1 and 2 working fine but not the 3rd one.
Is anything in Manifest file blocks the push messages?
Is there any permissions I missed?
Note : I am using the trail version.

Related

Push notifications not working when my app is closed in react native firebase

i did not any receive fcm when my app is closed
in foreground and open state i received but in background state not working
i think all my code is ok but not receive
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.sample_project">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="#style/AppTheme"
>
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="#string/default_notification_channel_id"/>
<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#mipmap/ic_launcher"/>
<receiver android:name="io.invertase.firebase.notifications.RNFirebaseNotificationReceiver"/>
<receiver android:enabled="true" android:exported="true" android:name="io.invertase.firebase.notifications.RNFirebaseNotificationsRebootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.infuy.toshisanapp" />
</intent-filter>
</receiver>
<service android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionsService"/>
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
<service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait"
android:launchMode="singleTop"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
and in index file i put this
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import {firebaseBackgroundMessage} from "./res/Global/FcmManager";
AppRegistry.registerComponent(appName, () => App);
AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => firebaseBackgroundMessage);
and in firebaseBackgroundMessage i have this code
export async function firebaseBackgroundMessage(message: RemoteMessage) {
console.log("firebaseBackgroundMessage::::::::::::::::::::::::::::::");
let notif=message['data'];
console.log(JSON.stringify(message));
const groupNotificationId = 'test';
const body = 'Chats list';
const smallIcon = 'ic_launcher';
const channel = new firebase.notifications.Android.Channel(
"reminder", // channelId
"Reminders Channel", // channel name
firebase.notifications.Android.Importance.High // channel importance
).setDescription("Used for getting reminder notification"); // channel description
firebase.notifications().android.createChannel(channel);
const groupNotification = new firebase.notifications.Notification()
.setNotificationId(groupNotificationId)
.setSubtitle(body)
.setTitle(Data.data.title)
.setBody(Data.data.text)
groupNotification
.android.setGroup(groupNotificationId)
.android.setGroupSummary(true)
.android.setChannelId('reminder')
.android.setSmallIcon(smallIcon)
.android.setAutoCancel(true);
firebase.notifications().displayNotification(groupNotification);
return Promise.resolve();
}
plz help me
i did test more a lot of sample code and permission but not working
i am tired
and sample of package.json
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-firebase": "^5.5.6",
"react-navigation": "^4.1.0",
"react-navigation-stack": "^2.1.0",
You should created receiver which handles on device boot event and then create a background service which connects to firebase. In this case even if app terminated by user, service will work.
boot receiver sample:
public class MyReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
// do your coed
}
}
Which module you are using for push Notification?
Push Notification is working on iOS?

Xamarin Forms AndroidMainfest

This is my mainfest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.Notification">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="${com.companyname.Notification}.permission.C2D_MESSAGE" />
<permission android:name="${com.companyname.Notification}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<application android:label="Notification.Android" android:name="android.app.Application" android:allowBackup="true" android:icon="#mipmap/icon" android:debuggable="true">
<receiver android:name="com.onesignal.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="${com.companyname.Notification}" />
</intent-filter>
</receiver>
<activity android:configChanges="orientation|screenSize" android:icon="#mipmap/icon" android:label="Notification" android:theme="#style/MainTheme" android:name="md542ccf1b76a5e02a89cf2bd3ef3e134e4.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="md5dcb6eccdc824e0677ffae8ccdde42930.KeepAliveService" />
<receiver android:enabled="true" android:exported="false" android:name="md51558244f76c53b6aeda52c8a337f2c37.PowerSaveModeBroadcastReceiver" />
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="com.companyname.Notification.mono.MonoRuntimeProvider.__mono_init__" />
<!--suppress ExportedReceiver-->
<receiver android:name="mono.android.Seppuku">
<intent-filter>
<action android:name="mono.android.intent.action.SEPPUKU" />
<category android:name="mono.android.intent.category.SEPPUKU.com.companyname.Notification" />
</intent-filter>
</receiver>
<receiver android:name="com.onesignal.NotificationOpenedReceiver" />
<service android:name="com.onesignal.GcmIntentService" />
<service android:name="com.onesignal.GcmIntentJobService" android:permission="android.permission.BIND_JOB_SERVICE" />
<service android:name="com.onesignal.RestoreJobService" android:permission="android.permission.BIND_JOB_SERVICE" />
<service android:name="com.onesignal.RestoreKickoffJobService" android:permission="android.permission.BIND_JOB_SERVICE" />
<service android:name="com.onesignal.SyncService" android:stopWithTask="true" />
<service android:name="com.onesignal.SyncJobService" android:permission="android.permission.BIND_JOB_SERVICE" />
<activity android:name="com.onesignal.PermissionsActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<service android:name="com.onesignal.NotificationRestoreService" />
<receiver android:name="com.onesignal.BootUpReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<receiver android:name="com.onesignal.UpgradeReceiver">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<activity android:name="com.google.android.gms.common.api.GoogleApiActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar" android:exported="false" />
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
</application>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.sec.android.provider.badge.permission.READ" />
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" />
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT" />
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE" />
<uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE" />
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT" />
<uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE" />
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" />
<uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.READ_APP_BADGE" />
<uses-permission android:name="com.oppo.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS" />
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_READ" />
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_WRITE" />
</manifest>
I keep getting these errors and I don't know what is wrong!!
Severity Code Description Project File Line Suppression State
Error Tag attribute name has invalid character '$'. Notification.Android C:\Users\moham\source\repos\Notification\Notification\Notification.Android\obj\Debug\81\android\manifest\AndroidManifest.xml 14
Severity Code Description Project File Line Suppression State
Error Tag attribute name has invalid character '$'. Notification.Android C:\Users\moham\source\repos\Notification\Notification\Notification.Android\obj\Debug\81\android\manifest\AndroidManifest.xml 9
Severity Code Description Project File Line Suppression State
Error Could not copy the file "obj\x86\Debug\MainPage.xbf" because it was not found. AppXamarin.UWP
Anyone can help?
You seem to be configuring OneSignal push notifications but you haven't changed the android:name="${com.companyname.Notification}" where the name of it should actually be your apps package name which is this com.companyname.Notification in your case

Fcm Notification not Coming when App is in Kill State in React Native

When sending from FCM i.e Firebase console in react native it is easily coming in iOS and Android both but when i am sending notification from admin or backend side it is not coming when app is in kill state.
I am using react-native-fcm .
Thanx .
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/brainbg"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:launchMode="singleTop"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher"/>
<receiver android:enabled="true" android:exported="true" android:name="com.evollu.react.fcm.FIRSystemBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
I had the same issue, resolved it by adding the code below after receiving the fcm token,
FCM.setBadgeNumber(0);
Above is for android for iOS you need to turn on background notifications in Xcode. In Xcode select your project and open capabilities and see if background modes in on. Refer to the screenshot
Here is the snippet of the code i used
export const MyNotificationReceiver = props => {
FCM.getInitialNotification().then(notif => {
});
FCM.setBadgeNumber(0); //Add this for background notification
this.notificationListener = FCM.on(FCMEvent.Notification, async notif => {
var notification_messgae = "";
try {
notification_messgae = notif.default;
} catch (error) {
notification_messgae = JSON.stringify(notif);
}
if (osDetection) {
switch (notif._notificationType) {
case NotificationType.Remote:
notif.finish(RemoteNotificationResult.NewData) //other types available: RemoteNotificationResult.NewData, RemoteNotificationResult.ResultFailed
break;
case NotificationType.NotificationResponse:
notif.finish();
break;
case NotificationType.WillPresent:
notif.finish(WillPresentNotificationResult.All) //other types available: WillPresentNotificationResult.None
break;
}
}
if (!osDetection()) {
if(notif.default)
{
FCM.presentLocalNotification({
body: notif.default,
priority: "high",
show_in_foreground: true,
large_icon: "noti_icon", // Android only
icon: "noti_icon", // as FCM payload, you can relace this with custom icon you put in mipmap
android_actions: JSON.stringify([{
id: "view",
title: 'view'
}, {
id: "dismiss",
title: 'dismiss'
}]) // for android, take syntax similar to ios's. only buttons are supported
});
}
}
});
};

Android push notification not receive when internet is ON

1) I have implement the push notification.It works fine when device is connected to Internet.(i-e) receive notification from server side
2) when the device is not connected to Internet. if server send the push message.and then when the device is connected to Internet..it not receiving the push message .. this is the problem
3) It like to implement push message like whats app..when the device is connect to Internet ..it should receive the push message..
public class GcmIntentService extends GcmListenerService {
#Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("title");
String post_id=data.getString("id");
boolean pushactive= SharedPreference.getInstance().getBool(this,"pushactive");
if(pushactive)
generateNotification(message,post_id);
}
#Override
public void onCreate() {
super.onCreate();
System.out.println("inside GcmListenerService");
}
public void generateNotification(String message,String post_id)
{
Random random = new Random();
int m = random.nextInt(9999 - 1000) + 1000;
Intent intent = new Intent(this, NewsDetailActivity.class);
intent.putExtra("isPush", true);
intent.putExtra("post_id",post_id);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentText(message)
.setContentTitle("EGToday")
.setAutoCancel(true)
.setContentIntent(PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
notificationManager.notify(m, mBuilder.build());
}
}
how to achieve this?
This is my intent service class.
this is my manifeast
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.egt">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission android:name="com.egt.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.egt.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:name="com.egt.Constants.NetworkCall"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".View.SplashPage">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:windowSoftInputMode="stateHidden|adjustPan"
android:name=".View.MainActivity"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".View.NewsDetailActivity"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".View.SearchActivity"
android:screenOrientation="portrait">
</activity>
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true"
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.egt" />
</intent-filter>
</receiver>
<service
android:name="com.egt.PushNotification.GcmIntentService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service android:name="com.egt.PushNotification.GcmRegistration"
android:exported="false" />
</application>
</manifest>
In your server side set delayWhileIdle(true)
If the device is connected but idle, the message will still be
delivered right away unless the delay_while_idle flag is set to true.
Otherwise, it will be stored in the GCM servers until the device is
awake. And that's where the collapse_key flag plays a role: if there
is already a message with the same collapse key (and registration ID)
stored and waiting for delivery, the old message will be discarded and
the new message will take its place (that is, the old message will be
collapsed by the new one).
Ex.
Message message = new Message.Builder().delayWhileIdle(true).addData(MESSAGE_KEY,text).build();

not receiving pushNotification in android

I had configured gcm pushnotification client receiver for android. The server is receiving send success response from google but the message is not receiving at the client side device. The app server uses gcm_on_rails gem for sending push notification (gcm_on_rails link: https://github.com/dondeng/gcm_on_rails implemenntation). I am stuck at this point for several days, any helps will be appreciate.
This is my Manifest file :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.glympse.android.sendlite"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- GLYMPSE API - Needed to send Glympses via SMS -->
<uses-permission android:name="android.permission.SEND_SMS" />
<!-- GLYMPSE API - Needed to read contacts if using the Recipients editor from the Send Wizard -->
<uses-permission android:name="android.permission.READ_CONTACTS" />
<!-- GLYMPSE API - Used to query network connection status before attempting network activity -->
<!-- Docs: Allows applications to access information about networks -->
<!-- Install: View network connections -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- GLYMPSE API - Used to create a default user profile (nickname/avatar) -->
<!-- Optional but highly recommended -->
<!-- Docs: Allows an application to read the user's contacts data. -->
<!-- Install: Read your contacts -->
<uses-permission android:name="android.permission.READ_CONTACTS" />
<!-- GLYMPSE API - Used to create a default user profile (nickname/avatar) -->
<!-- Optional but highly recommended -->
<!-- Docs: Allows an application to read the user's personal profile data. -->
<!-- Install: Read your own contact card -->
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.glympse.android.sendlite.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.glympse.android.sendlite.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:theme="#style/AppTheme"
android:label="#string/app_name" >
<activity
android:name=".ChaffeoSplash"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.glympse.android.login.MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.glympse.android.home.Home"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.glympse.android.acceptrejectrides.ShowMyList"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".IndividualBookings"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".NoRidesAccRej"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.glympse.android.yourrides.YourRides"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".DetailsActivity"
android:configChanges="orientation|keyboardHidden"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name=".StartRide"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".FullscreenActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".NoRidesYourRides"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".TabGroupActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".TabGroup1Activity"
android:screenOrientation="portrait" >
</activity>
<activity android:name=".TabsActivity" >
</activity>
<activity
android:name=".TabsActivity2"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".TabsActivity1"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".GlympseSendLiteDemoActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:screenOrientation="portrait" >
</activity>
<!-- GLYMPSE API - This is required to make the GlympseSendWizard configurator work. -->
<activity
android:name="com.glympse.android.kit.send.GlympseSendWizard"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize" >
</activity>
<!-- GLYMPSE API - This is required to be notified, when Glympse service is restarted. -->
<receiver
android:name=".GlympseLiteWrapper$ServiceReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.glympse.android.hal.service.STARTED" />
</intent-filter>
</receiver>
<activity
android:name=".EndRide" >
</activity>
<receiver
android:name="com.glympse.android.notifications.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="com.glympse.android.sendlite" />
</intent-filter>
</receiver>
<service android:name="com.glympse.android.notifications.GCMNotificationIntentService" />
</application>
</manifest>
This is my Broadcast receiver :
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.widget.Toast;
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
// Explicitly specify that GcmIntentService will handle the intent.
ComponentName comp = new ComponentName(context.getPackageName(),
GCMNotificationIntentService.class.getName());
// Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}
This is my GCM service class :
public class GCMNotificationIntentService extends IntentService {
public static final int NOTIFICATION_ID = 1;
private NotificationManager mNotificationManager;
NotificationCompat.Builder builder;
public GCMNotificationIntentService() {
super("GcmIntentService");
}
public static final String TAG = "GCMNotificationIntentService";
#Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
String msg = intent.getStringExtra("message");
System.out.println("###############GCM Message type---> " + messageType);
System.out.println("GCM intent.getStringExtra()---> " + msg);
if (!extras.isEmpty()) {
if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
.equals(messageType)) {
sendNotification("Send error: " + extras.toString());
}
else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
.equals(messageType)) {
sendNotification("Deleted messages on server: "
+ extras.toString());
}
else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE
.equals(messageType)) {
for (int i = 0; i < 3; i++) {
Log.i(TAG,
"Working... " + (i + 1) + "/5 # "
+ SystemClock.elapsedRealtime());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
}
Log.i(TAG, "Completed work # " + SystemClock.elapsedRealtime());
// sendNotification(""+extras.get(DriverUtils.MESSAGE_KEY));
sendNotification(""+extras.get("message"));
Log.i(TAG, "Received: " + extras.toString());
System.out.println("GCM GCM GCM" + extras.toString());
}
}
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
#SuppressLint("NewApi")
private void sendNotification(String msg) {
System.out.println("MESSAGE : " + msg);
// Prepare intent which is triggered if the
// notification is selected
Intent intent = new Intent(this, ChaffeoSplash.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
// Build notification
// Actions are just fake
Notification noti = new Notification.Builder(this)
.setContentTitle("Chaffeo")
.setContentText(msg)
.setSmallIcon(R.drawable.icon)
.setContentIntent(pIntent).build();
noti.flags |= Notification.FLAG_AUTO_CANCEL;// hide the notification after its selected
noti.defaults |= Notification.DEFAULT_VIBRATE;
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// hide the notification after its selected
notificationManager.notify(0, noti);
}
}
Could any one help me solving this problem, thanks in advance.
Note that in the following code :
// Explicitly specify that GcmIntentService will handle the intent.
ComponentName comp = new ComponentName(context.getPackageName(),
GCMNotificationIntentService.class.getName());
you are saying that the GCMNotificationIntentService is located in the main package of the application. However, your GCMNotificationIntentService is located in com.glympse.android.notifications, while the main package of your app is com.glympse.android.sendlite.
You can fix it this way :
// Explicitly specify that GcmIntentService will handle the intent.
ComponentName comp = new ComponentName(GCMNotificationIntentService.class.getPackage().getName(),
GCMNotificationIntentService.class.getName());

Resources