I added local notification in my ionic application using the below code and was working good.but there is an issue on iOS
https://ionicframework.com/docs/native/local-notifications/
this.localNotifications.schedule({
id: 1,
text: 'Single ILocalNotification',
sound: isAndroid? 'file://sound.mp3': 'file://beep.caf',
data: { secret: key }
});
This is not working on IOS ,if we open application from background.
Error replicate steps.
1.Open applicaton
2.Minimize application in the background
3.Open application from background.
4.After this the notification was not showing on the status bar,but we can here the notification sound
Related
Been working on an Ionic app, the app runs well on Android, however when adding push notification services the app simply shows a blank screen after the splash screen and doesn't load the app from "ionic://localhost/" instead loads from "file://" after removing the push service the app works well again on all platforms.
We are using the cordova-plugin-firebasex plugin for push notifications.
The error from Xcode when running the app is: "Failed to load webpage with error:...."
I'm using cordova-plugin-firebase. On Android everything works fine, on iOS when I send push message via FireBase Console it appears only in xCode console:
Received data message: {
"collapse_key" = "myapp.id";
from = 932472342376;
notification = {
body = "Some notification";
e = 1;
sound = default;
sound2 = default;
};
It appears only in console so I guess everything is setup correctly (like certificates, .plist file). How to force iOS to show this notification? I'm using latest version of xCode, Cordova and this plugin.
In app capabilities I also checked Background Modes - Remote Nofitications and Push Notifications but without changes.
It is also worth to say that this message comes only if app is opened, phone home button click indicates in console message: "Disconnected from FCM". Shouldn't it be connected instantly?
I used the local notification plug in for an Android and iOS application. It worked properly with the Android Application but I faced issues with the IOS application.
When used in iOS application I didn't receive any notifications.
For your reference I am sending a sample code which I have used in my application:
window.plugin.notification.local.add({
id: i,
message: "Hello",
icon: 'file://img/icon.png',
sound: '/www/audio/beep.mp3',
badge: i,
json: JSON.stringify({ test: 123 })
});
using plugin: de.appplant.cordova.plugin.local-notification-sv
I’m working on the iOS version of my phonegap-based navigation app. My app tracks the user’s location around a walk route using GPS and alerts the user using audio (navigator.notification.beep) and tactile (navigator.notification.vibrate) feedback when they reach a location at which there’s new instructions for them to follow.
When my app is running in the foreground, both the audible beep and the vibration fire on reaching the geographic location but when the app is paused in the background, either by pressing the power button to turn the screen off or pressing the home button to return to the springboard, only the vibration works - the beep is not audible. I’ve added debug so I can see in the log file that the app is calling navigator.notification.beep() while in the background but the beep sound isn't made. I’ve tested my app on an iPhone 4S running iOS 6.3.1 and iPad 2 running iOS 5.1.1. Obviously the iPad doesn’t vibrate but the beep works while the app is in the foreground but not when in the background.
My app is using Phonegap 2.5.0
I’m using latest Xcode v4.6.2 with latest SDK for iOS 6.3.1
I’m using a beep.wav in the /www root
My app’s .plist sets “UIBackgroundModes” of “location” and “audio”
My config.xml contains the settings:
<plugin name="Notification" value="CDVNotification" />
<plugin name="Media" value="CDVSound" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="AllowInlineMediaPlayback" value="true" />
Any suggestions how to fix this would be most appreciated :-)
In case anyone else in interested, here’s how I solved this:
I updated the Local Notifications phonegap plugin for use with Cordova 2.x. I used the plugin to provide the background beep and phonegap for the foreground beep by placing the same sound for phonegap in www/ as beep.wav as for the local notification in the iOS project Resources as beep.caf.
function doBeep(){
cordova.require('cordova/plugin/localnotification').add(
function(){
console.log("Successfully added local notification");
},
function(){
console.error("Error adding local notification");
},{
date: new Date(new Date().getTime()),
repeat:'',
message: '', // No message so just beep
hasAction: true,
badge: 0,
id: '1',
background:'background',
foreground:'running',
sound: 'beep.caf'
}
);
}
function running(){
console.log("Running in the foreground so use a phonegap notification");
navigator.notification.beep();
}
function background(){
console.log("Running in the background so an iOS local notification will be used");
}
Summary: successfully created a native iOS app in Sencha Touch 2.1 (and 2.2alpha) with a custom URL scheme. In both iOS Simulator and on a real device, launching the app from cold using the custom URL does not pass the URL to the app (Ext.device.Device.scheme is always false, regardless of whether you start the app using the custom URL or not). If the app is already running in the background, however, then the custom URL used to resume it is successfully passed to the schemeupdate event. The launching-from-cold behavior is not consistent with the documentation, and I need a workaround to get the custom URL when the app is started from cold.
Details:
Following the instructions at http://docs.sencha.com/touch/2-1/#!/api/Ext.device.Device to specify a Custom Scheme URL for my native iOS app. I am building on OS X Lion with XCode 4.5.1.
This occurs on both Sencha Touch 2.1 and 2.2alpha and on both iOS 5 and iOS 6.
Steps to reproduce:
Generate a new app using:
$ sencha generate app -path /Library/WebServer/Documents/SchemeTest
Add 'Ext.device.Device' to the requires: property of the application as per the documentation linked above.
Add the following code to the launch function in app.js:
alert("Scheme is " + Ext.device.Device.scheme);
if (Ext.device.Device.scheme) {
// the application was opened via another application. Do something:
alert('Applicaton pened via another application: ' + Ext.device.Device.scheme.url);
}
// Listen for future changes
Ext.device.Device.on('schemeupdate', function(device, scheme) {
// the application was launched, closed, and then launched another from another application
// this means onReady wont be called again ('cause the application is already running in the
// background) - but this event will be fired
alert('Applicated reopened via another application: ' + scheme.url);
}, this);
Specify a custom URL scheme by adding the following line to packager.json:
"rawConfig": "<key>CFBundleURLTypes</key><array><dict><key>CFBundleURLSchemes</key><array><string>sencha</string></array><key>CFBundleURLName</key><string>com.sencha.example</string></dict></array>"
This will cause URLs of the form sencha:HereIsMyURL to open your app on an iOS device or the iOS Simulator.
Run the app in iOS Simulator with this command:
$ sencha package run packager.json
The app will start in the iOS Simulator and will show the URL scheme to be false, since the app has not been started using a custom URL:
Click OK to close the alert dialog, then press the Home button on the iOS Simulator to move the app to the background. Open Mobile Safari and enter the URL sencha:HereIsMyURL and press Enter or click the Go button to resume the app:
The app will reopen and you will see the URL has been correctly passed in:
Tap the Home button on iOS Simulator, then double-tap the Home button and hold the mouse button down on the "My Application" icon until the icons start to shake. Use the red "-" to completely kill "My Application" so that it's no longer running:
Press the Home button again, then go back into Mobile Safari and re-enter the URL sencha:HereIsMyURL and press Enter or click the Go button to start the app.
The app will start, but Ext.device.Device.scheme is still false and so the URL cannot be retrieved.
(Optional) Configure your packager.json file with a valid applicationName, applicationId, bundleSeedId, certificateAlias and provisionProfile, and set the platform to iOS. Then rebuild your native app for your real iOS device using $ sencha package build packager.json, copy the app to your device using XCode, and repeat steps 7 through 11 on the real device. The results are the same.
This means that it is only possible to retrieve a custom URL when the app is already running in the background. When starting the app from cold using a custom URL, the app does not correctly detect that a custom URL scheme has been used and so it is not possible to pass information to the app. Does anyone know of a workaround for this?
I have filed a bug report which can be seen at http://www.sencha.com/forum/showthread.php?254153-ST-2.1-and-2.2alpha-Ext.device.Device.scheme-is-false-on-launch-from-custom-URL.