Giter Site home page Giter Site logo

Comments (17)

welshrat avatar welshrat commented on June 22, 2024

Yes I am experiencing the same issue, none of my jsbridge events are firing with latest xamarin release, any help much appreciated as my app is now broken :-(

from jsbridge.

volaticus avatar volaticus commented on June 22, 2024

Issue gone with today's stable release (Xamarin v.6.4.0.2). Sample now works as expected.

from jsbridge.

cdeutsch avatar cdeutsch commented on June 22, 2024

Thanks for the update @volaticus. Let me know if it stops working again. I'll leave this open for a day or two in case others run into it.

I'm glad Xamarin fixed it because I kind of expected I wouldn't be able to. ;)

Also, good to see some people using this library. I'm open to ideas on how to make it better.

from jsbridge.

welshrat avatar welshrat commented on June 22, 2024

Hi crdeutch, I am still experiencing the same issue (Xamarin v.6.4.0.2), all my cdeutsch.JsBridge.AddEventListener simply never fire, I updated JSBridge and xamarin and although my app compiles ok the events simply wont fire. was all working fine up until the updates.

Any more info welcome, and yes a great library :-)

EDIT - Apologies I had not update the mt.js file, normal service has resumed.

from jsbridge.

cdeutsch avatar cdeutsch commented on June 22, 2024

Hey @welshrat, I just updated mine to 6.4.0.2 and I'm not having the issue.

Double check you have 6.4.0.2. In Xamarin Studio go to the menu:
"Xamarin Studio -> About Xamarin Studio"
Click the "Show Details" button

Does the example app work for you?

Another thing to try would be to right click the project and do "Clean "

from jsbridge.

welshrat avatar welshrat commented on June 22, 2024

Hi crdeutch, all fixed, sorry I had updated JSBridge but not replaced the mt.js file.

Many thanks and keep up the great work

from jsbridge.

borodk avatar borodk commented on June 22, 2024

Thanks! I was having the same issue with 6.4.0.2, but updating JSBridge and mt.js fixed the problem. Great library.

from jsbridge.

svenessar avatar svenessar commented on June 22, 2024

Hello,

great work :-)
Only one question for your example:

viewController.WebView.AddEventListener( "promptUser", delegate(FireEventData arg) {
// show a native action sheet
BeginInvokeOnMainThread (delegate {
var sheet = new UIActionSheet ( arg.Data["question"].ToString() );
sheet.AddButton ( "Yes" );
sheet.AddButton ( "No" );
sheet.CancelButtonIndex = 1;
sheet.ShowInView ( viewController.View );
});
});

How i can wait in Javascript for the clicked button result?

Best regards
Sven

from jsbridge.

cdeutsch avatar cdeutsch commented on June 22, 2024

@svenessar this isn't really related to the issue, which I will be closing after this, but here's an answer.

You need to fire an event after the sheet is Clicked. So wire up the sheet "Clicked" event and in it call FireEvent.

sheet.Clicked += delegate(object s, UIButtonEventArgs e) {
    viewController.WebView.FireEvent( "sheetActionClicked", new {
        buttonIndex = e.ButtonIndex,
        extraParams = "Customize Me"
    });
};
sheet.ShowInView ( viewController.View );

You then need to handle this event in your javascript:

Mt.App.addEventListener('sheetActionClicked', function(data) {
    if (data.buttonIndex == 0) {
        console.log('button 0 clicked');
    }
    else if (data.buttonIndex == 1) {
        console.log('button 1 clicked');
    }       
});

Shoot me an email at [email protected] if you have more questions.

from jsbridge.

svenessar avatar svenessar commented on June 22, 2024

Hello Christopher,

sorry for my post, you are right. It is not an issue. :- )
Thank you for your answer, but is seems that will be fired async, right?

The point is, that the JS will not wait for the answer. Is there a way to wait in JS for the answer with Native call?

My JS should be work syncron with the Native world.

Thank you so much.

Sven

Von: Christopher Deutsch [mailto:[email protected]]
Gesendet: Freitag, 20. September 2013 20:52
An: crdeutsch/MonoTouch-JsBridge
Cc: Sven Reißenweber
Betreff: Re: [MonoTouch-JsBridge] Seems that JsBridge not working with Xamarin.iOS Version: 6.2.7.1 (#3)

@svenessarhttps://github.com/svenessar this isn't really related to the issue, which I will be closing after this, but here's an answer.

You need to fire an event after the sheet is Clicked. So wire up the sheet "Clicked" event and in it call FireEvent.

sheet.Clicked += delegate(object s, UIButtonEventArgs e) {

viewController.WebView.FireEvent( "sheetActionClicked", new {

    buttonIndex = e.ButtonIndex,

    extraParams = "Customize Me"

});

};

sheet.ShowInView ( viewController.View );

You then need to handle this event in your javascript:

Mt.App.addEventListener('sheetActionClicked', function(data) {

if (data.buttonIndex == 0) {

    console.log('button 0 clicked');

}

else if (data.buttonIndex == 1) {

    console.log('button 1 clicked');

}

});

Shoot me an email at [email protected]:[email protected] if you have more questions.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-24832683.

from jsbridge.

cdeutsch avatar cdeutsch commented on June 22, 2024

It's more "event driven" then Async.

When you "wire up" the Clicked event that code doesn't execute until the Action Sheet is clicked so that is where the "waiting" is done. So it should work.

Give it a try.

from jsbridge.

svenessar avatar svenessar commented on June 22, 2024

Sorry it is async, maybe i am to stupid :- (

i used your example index.html:

window.onload = function(e) {
console.log( 'loaded' );

            Mt.API.info( 'log "loaded" call on native side' );

                                                           // listen for doBrowserStuff event triggered from native code.
                                                           Mt.App.addEventListener('doBrowserStuff', function(data) {

                                                                          console.log('doBrowserStuff Callback:');
                                                                          console.log(data.Message);

                                                           });

                                                           // fire doNativeStuff in native code.
                                                           Mt.App.fireEvent('doNativeStuff', {
                msg: 'Hi, this msg is from the browser.',
                extra: 'You can send more then one property back',
                answer: 42
            });

            Mt.App.addEventListener('sheetActionClicked', function(data) {
                if (data.buttonIndex == 0) {
                    console.log('button 0 clicked');
                }
                else if (data.buttonIndex == 1) {
                    console.log('button 1 clicked');
                }
            });
            console.log('finish');
                                           };

è console.log('finish'); is executed before the 'sheetActionClicked' has an answer :- (

could you help me please?
The complete JS should work syncron and wait, before execute with the next line of code, for the native result.

Thank you so much
Sven

Von: Christopher Deutsch [mailto:[email protected]]
Gesendet: Freitag, 20. September 2013 21:05
An: crdeutsch/MonoTouch-JsBridge
Cc: Sven Reißenweber
Betreff: Re: [MonoTouch-JsBridge] Seems that JsBridge not working with Xamarin.iOS Version: 6.2.7.1 (#3)

It's more "event driven" then Async.

When you "wire up" the Clicked event that code doesn't execute until the Action Sheet is clicked so that is where the "waiting" is done. So it should work.

Give it a try.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-24833958.

from jsbridge.

cdeutsch avatar cdeutsch commented on June 22, 2024

If you zip up your code and email it to [email protected] I can take a look

from jsbridge.

svenessar avatar svenessar commented on June 22, 2024

I modifyed your index.html

For your backround:

I use JavaScript like native code. So I call a function syncron wait for the result, take the result from the first function and call the next function with this result.

Like native

Thank you
Sven

Von: Christopher Deutsch [mailto:[email protected]]
Gesendet: Freitag, 20. September 2013 21:20
An: crdeutsch/MonoTouch-JsBridge
Cc: Sven Reißenweber
Betreff: Re: [MonoTouch-JsBridge] Seems that JsBridge not working with Xamarin.iOS Version: 6.2.7.1 (#3)

If you zip up and code and email it to [email protected]:[email protected] I can take a look


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-24834905.

from jsbridge.

cdeutsch avatar cdeutsch commented on June 22, 2024

You can't do synchronous programming between native and js. It has to be event driven.

If you send the code I can modify it to do what you want. It makes sense that "finish" is called first because it's not inside the function that handles the event.

from jsbridge.

svenessar avatar svenessar commented on June 22, 2024

This is a running JS Code in Android:

var anvintscr_srcTbl = new recTbl(RTObj.CurrSSRecTblId);
var anvintscr_destTbl;var anvintscr_scriptName = '';
anvintscr_scriptName += anvintscr_srcTbl.GETTABLENO();anvintscr_scriptName += '_5050';
if (PAGE.EXISTPREPAREFN(anvintscr_scriptName)){anvintscr_destTbl = new recTbl(PAGE.OPENPREPARE(anvintscr_scriptName,anvintscr_srcTbl.tblID));} else {anvintscr_destTbl = new Table('Contact');}anvintscr_srcTbl.KEEPINMEMORY();
if (anvintscr_destTbl.FINDFIRST()) {PAGE.OPEN('CONTACT_CARD',anvintscr_destTbl.tblID,anvintscr_srcTbl.tblID);} else { DIALOG.ERROR('No records found.') }

in Android I use WebChromeClient with OnJsPrompt (delegated to Native), the webview wait for the prompt result and execute the next code.

Do you have any idea how I can develop this with ios?

Von: Christopher Deutsch [mailto:[email protected]]
Gesendet: Freitag, 20. September 2013 21:35
An: crdeutsch/MonoTouch-JsBridge
Cc: Sven Reißenweber
Betreff: Re: [MonoTouch-JsBridge] Seems that JsBridge not working with Xamarin.iOS Version: 6.2.7.1 (#3)

You can't do synchronous programming between native and js. It has to be event driven.

If you send the code I can modify it to do what you want. It makes sense that "finish" is called first because it's not inside the function that handles the event.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-24835843.

from jsbridge.

cdeutsch avatar cdeutsch commented on June 22, 2024

Everything you want to do after the prompt results just needs to go inside the event handler function. Just like you were using jQuery and handling a button click it's the same thing.

Mt.App.addEventListener('sheetActionClicked', function(data) {
    // put the code you want to execute after the button here
});

// do NOT put the code here

Please use my email if you have more questions. There are other people subscribed to this thread on GitHub they don't need to keep getting notified.

from jsbridge.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.