PhoneGap Events Not Firing On iPhone - iphone

I've started developing for iPhone using PhoneGap and an iPhone running iOS 5. With the following code, the deviceready and online events appear to fire when the application starts but none of the others, in particular, the resume / pause events appear to. I've tried using the menu button to close the app and then re-open it but nothing appears to fire the resume event.
If anyone could shed any light on this it would be much appreciated.
Thanks in advance!
window.addEventListener('load', function () {
document.addEventListener('deviceready', onDeviceReady, false);
}, false);
function onDeviceReady() {
document.addEventListener('resume', onResume, false);
document.addEventListener('pause', onPause, false);
document.addEventListener('online', onOnline, false);
document.addEventListener('offline', onOffline, false);
}
function onResume() {
alert('resume');
}
function onPause() {
alert('pause');
}
function onOnline() {
alert('online');
}
function onOffline() {
alert('offline');
}

For me this was an ID10-T error: my PhoneGap app was redirecting to a URL which I had changed in one place but not in the other. The result was it looked like I was running my development code but I was actually running against a remote server running code without onResume and onPause events!
BTW, documentation for these events can be found at http://docs.phonegap.com/en/1.4.1/phonegap_events_events.md.html

Related

Not receiving firebase dynamic link

Currently I am doing a project that calls a secondary app and I launch the 2nd app through InAppWebView. While the 2nd app is facing the user, the inappwebview is still running and sends live update, which I am capturing to trigger events, for example like it will send payment complete, allowing me to trigger to go summary page.
The issue I am having is, I am unable to smoothly transit back to my app. So there are two ways that I found that allow me to go back to the app.
One, launch the URL using my dynamic link but this method I am unable to receive the link.
Second, to launch it through external application like chrome.
The second method works perfectly other than the fact that the screen jumps to chrome. And it continues from where I left off.
However, what I want is both, continue from where I left off and not have the jumping of the chrome. Or from what I have read the right way is to direct to the activity using intent filter. But the smooth method I am not receiving the links but the jump method I am receiving the links.
Please help T - T
if you need to add dynamic links with firebase you can find the setup right in the docs and with the help with firebase_dynamic_links you can handle where to go inside your app and also can execute parameters from the link in the function below you make a stream that listen to any dynamic link clicked while the app in the background or foreground , the PendingDynamicLinkData is when the app terminated. the business logic and how the app interacts ups to you.
static Future<void> initDynamicLink() async {
FirebaseDynamicLinks.instance.onLink.listen((dynamicLink) async {
if (dynamicLink.link != Uri.parse("uri")) {
log(dynamicLink.link.queryParameters.toString());
final Uri deepLink = dynamicLink.link;
// you should handle the navigation or you logic here
}
}).onError((error) {
debugPrint("error from dynamic link Stream : : :: ${error.toString()}");
});
final PendingDynamicLinkData? initialLink =
await FirebaseDynamicLinks.instance.getInitialLink();
try {
if (initialLink != null) {
log(initialLink.link.toString());
final Uri deepLink = dynamicLink.link;
// you should handle the navigation or you logic here
}
} catch (e) {
debugPrint('No deepLink found');
}
}
don't forget to call this function in the main like this
void main()async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
initDynamicLink();
}

Flutter Desktop Ignore Mouse Events

I'm looking to implement a Flutter Desktop application that allows a transparent window which forwards all touch events, like Zoom screen share.
My understanding is the behaviour can be achieved in electron using:
mainWindow.setIgnoreMouseEvents(true);
const el = document.getElementById('clickThroughElement');
el.addEventListener('mouseenter', () => {
mainWindow.setIgnoreMouseEvents(true, { forward: true });
});
el.addEventListener('mouseleave', () => {
mainWindow.setIgnoreMouseEvents(false);
});
};
With Flutter Desktop still being in Alpha,
Is this feature possible?
Is there another approach?
Is it on the feature radar?
you need to change the native C++ code specifically in
windows\runner\win32_window.cpp
and comment's the SetWindowLongPtr() function
and add the following code
int extendedStyleSettings = GetWindowLong(window,GWL_EXSTYLE);
SetWindowLong(window,GWL_EXSTYLE, extendedStyleSettings | WS_EX_LAYERED | WS_EX_TRANSPARENT);
SetLayeredWindowAttributes(window, 0, 255, LWA_ALPHA);
The problem with this solution is I don't know how to get the mouse event back because this solution edit's the win32api window which initiating in the begging of the running app and hosting the flutter view

Close Unity Inside Android App

Actually I have an Android App in which I run my Unity3D game. Everything works well together. Now, when I launch Unity inside my app the game starts normally but if I try to go back to my AndroidApp intent I received a "SIGNAL 11 SIGSEGV" and Unity just close.
This happens when I'm drawing a Menu inside Unity and press "Exit" button to close Unity but if I do the same with the Android back buton Unity closes normally without problems.
I'm using plugins in Unity to achieve this behaviour.
My Function in Unity Side :
public void ExitGame()
{
#if UNITY_ANDROID
AndroidJavaClass unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject> ("currentActivity");
activity.Call ("ReturnToMainActivity", "Hello");
#endif
}
Function in Android Side :
public void ReturnToMainActivity (String someText)
{
Log.v("Unity", "Finish Unity from Android" );
this.mUnityPlayer.quit();
UnityPlayer.currentActivity.finish();
}
Again, this works normally if I press the Android Back Button inside Unity app but when I try to do the same with an Unity GUI.Button I received a "SIGNAL 11 SIGSEGV". In Both Cases logcat print the message "Finish Unity from Android" so I think Unity calls the function normally but in some Point just crashes.
Someone post faced the same problem but I can't figure out how he solve it.
SIGNAL 11 SIGSEGV crash Android
Ok, I just figure out how to do this.
In my function inside Android Side:
public void ReturnToMainActivity (String someText)
{
UnityPlayer.currentActivity.runOnUiThread(new Runnable(){
public void run()
{
Log.v("Unity", "Aplicacion de Unity terminada desde Android" );
ElJuegoActivity.this.mUnityPlayer.quit();
UnityPlayer.currentActivity.finish();
}
});
}
And that does the trick. No issues or problems.
NOTE: This is the "answer" the OP originally included at the end of his question. I've separated it into its own CW answer. If the OP returns and wants to post it himself, by all means ping me

Backbone app (w. require & cordova) iphone emulation vs device

I have a backbone app running with require and cordova. It runs perfectly in the browser and when emulating through xcode on all devices. But for whatever reason when I attempt to run it through the device (iphone 5) it starts up but never runs, instead only giving me a blank white screen. I have attempted to console log using cordova's console logging plugin which allows for console logs to be written to xcode's terminal, but it's consistency is shotty at best and i haven't gotten anything legitimate that could lead to a reason it runs on one but not the other.
Has anyone ever dealt with this? I know this is a very vague question, just trying to see if anyone has ever ran into the same issue more or less.
Here is the body of my index.html file...
<body>
<div id="container">loading...</div>
<script type="text/javascript" src="cordova.js"></script>
<script data-main="js/main" src="js/libs/require.js"></script>
</body>
Then this hits my main file, I am changing background color as a way of debugging, I am unable to change the background color from this file but I am able to in app.js ...
require.config({
baseUrl: "js/",
paths: {
jquery: 'libs/jquery/jquery-1.8.2',
underscore: 'libs/underscore/underscore-min',
backbone: 'libs/backbone/backbone-1.0.0-min',
text: 'libs/require/text',
templates: '../templates',
router: 'router',
app: 'app',
},
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
}
}
});
require(['app', 'router', 'models/SessionModel'], function(app, AppRouter, SessionModel) {
$('body').css('background-color', 'yellow');
document.addEventListener("deviceready", run, false);
function run() {
app.router = new AppRouter();
app.session = new SessionModel({});
app.session.checkAuth({
// Start the backbone routing once we have captured a user's auth status
complete: function(){
Backbone.history.start();
}
});
}
});
Then here is the very basic app file...
define([
"jquery",
"underscore",
"backbone"
],
function($, _, Backbone) {
var app = {
};
return app;
});
I guess you are getting an error even before the Cordova console plugin is loaded.
Try the following: Paste an alert message before the deviceReady event is fired.
Start the App, attach the Safari remote debugger and dispose the alert message, now you can see all the console output from there on. Most likely you will find a requirejs or cordova error there.

pause and resume listeners not working in phonegap on iOS4.3 and iOS 5

I was making a native app in iPhone4 with iOS 4.3
in my Body onLoad i m adding
document.addEventListener("pause", Game.prototype.pauseListener.bind(this), false);
document.addEventListener("resume", Game.prototype.resumeListener.bind(this), false);
and in that same file i m writing a function
Game.prototype.resumeListener= function()
{
console.log("in resumeListener");
this.PauseGame(false);
}
Game.prototype.pauseListener= function()
{
this.PauseGame(true);
}
this code is working perfectly fine in Android and when i manually minimise the app, but when the application is interrupted by a voice incoming call the application dont pause.
Basically Pause and Resume event are not fired.
I m using Phonegap1.4.1
I believe your event listeners are not being established because you are using Object.bind() on the handler functions, and .bind() is not available in the iOS WebKit widget. (This is surpising because .bind() is available in the desktop WebKit (Chrome and Safari) versions.)
The easy solution is to add a polyfill definition for Object.bind(). I use the one from the MDN bind documentation page, and haven't had any problems with it.
sorry but i cant make a comment yet ;)
have you checked the two other events (active and resign only for ios)? more information: http://shazronatadobe.wordpress.com/2012/03/14/apache-cordova-lifecycle-events-in-ios-4-versus-ios-5/
or see iOS Quirks in the documentation: http://docs.phonegap.com/en/1.6.1/cordova_events_events.md.html#pause
You need to add your listeners in the deviceready instead of in the onLoad.
Just like here for example
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
document.addEventListener("pause", onPause, false);
}
function onPause() {
}
Hope it helps :)