Closed sitefinitysteve closed 8 years ago
So I think my looking at the NS source I can create the broadcast reciever though JS which means I don't even need the custom .java activity...
I dont seem to ever HIT my reciever though... https://github.com/sitefinitysteve/nativescript-auth0/blob/master/plugin/index.android.js#L32
Hi @sitefinitysteve
...and what's this folder now?
-> F0platforms/android
folder. I have no idea how to implement this plugin ...
, But how to I get that data from there into here...
Why do the activity and application files get overwritten on every tns run? Makes it literally impossible to develop an app because you have to constantly monitor the files to see if they've been replaced.
Seemed okay in 1.7
Hi @sitefinitysteve,
The logic for these files can be entirely in their javascript counterparts. This means that the user shouldn't have to change anything in the platforms/android
folder. There will be a proposal soon that will allow for changed files not to be replaced, but that shouldn't be necessary.
Can you share what scenario, requires you to change the logic of the activity or application in the platforms/android
folder?
Auth0 plugin :/ works great on ios, but reeeeeally struggling with droid. I would love to not have to touch anything in the platform folder.
Like if i register the reciever in the .java i don't know how to send the result back to a js callback. But if i register the reciever in js, it doesn't seem to hit.
So like this seems okay in 1.7...aside from the inability to get the reciever result back into js
@sitefinitysteve as I see in the sample files provided here and here, you're adding logic in the lifecycle callbacks. You can achieve the same result if you move the logic surrounded by // AUTH0 START
and // AUTH0 END
to javascript.
The modules provide all application and activity callbacks you're using.
@Plamen5kov In your opinion then, I don't even NEED the custom java stuff?
Going on that, this is what I'm rockin right now... https://github.com/sitefinitysteve/nativescript-auth0/blob/master/plugin/index.android.js
But throws The application crashed because of an uncaught exception. You can look at "stackTrace" or "nativeException" for more detailed information about the exception. java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.demo/com.auth0.lock.LockActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.squareup.otto.Bus com.auth0.lock.Lock.getBus()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.squareup.otto.Bus com.auth0.lock.Lock.getBus()' on a null object reference at com.auth0.lock.LockActivity.onCreate(LockActivity.java:101) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) ... 10 more
Which makes me think the interface is important because I'm not sure how to impliment in JS https://github.com/sitefinitysteve/nativescript-auth0/blob/master/plugin/platforms/android/NativeScriptApplication.java#L18
Hi @sitefinitysteve, Currently there is no way of implementing the interface on the application, you can only implement the interface but not a class that implements an interface. If you like, you can open a new issue.
Thank you for trying to implement everything in javascript, it was very helpful to me and the team to know concrete examples and scenarios in order to better NativeScript.
@Plamen5kov So where do I go from here with these issues?
I suppose the main two are even if I can replace the platform/android/*/NativeScriptAppliction\Activity.java files directly, they just get constantly overwritten.
...and I dont seem to have any way to get the receiver to receive the data in JS so I can resolve my promise.
The entire process on the droid side has just been bumming me out for months, I feel like I'm just never gonna be able to get this Auth0 android-side plugin off the ground, where it works great on iOS.
Hi @sitefinitysteve, We think on implementing a solution where we will be able to know what files are not to be overridden. This way you'll be able to override the NativeScriptApplication and Activity files, as you have done up till now, until a more general solution is found. Unfortunately this fix will probably come with the next release.
There's no unfortunately in having to wait a few months, as long as the platform gets it!
Sidenote this popped up today as well https://groups.google.com/d/msgid/nativescript/53a371a4-f40e-4d12-a318-2f82613c5f84%40googlegroups.com
...we need working reliable oauth in {N}. Can you use this plugin to try to solve this ticket issue?
@Plamen5kov is this related to #283
No @valentinstoychev, this is a separate issue.
Separate, but along the same lines... can now customize the java files, but they keep getting overwritten in 2.0.
@sitefinitysteve Here is what we've come up with for 2.1: https://github.com/NativeScript/android-runtime/issues/465#issuecomment-228708260. Please note that your particular case - that is to extend the Application
object and implement an additional interface on it - will still not work through JavaScript (we already have this feature internally implemented but it will not ship for 2.1). However, because now the tns-core-modules
will not declare custom application class, as a workaround you can safely implement it in Java - it will not get overridden.
I am closing this issue for now. Let us know if you face some further issues once 2.1 is out (expected later this week).
Thx guys! I haven't had a chance to bump back to update the plugin, so I guess I should wait till 2.2? :+1:
Hey @sitefinitysteve, https://github.com/NativeScript/android-runtime/pull/501 hit the master branch yesterday, you could fetch the latest unstable build from android@next
and test away. We'd really appreciate any feedback about the feature, especially if there are any bugs or hints of unexpected behavior. The syntax is as per the issue description, we will have the information appended to our documents once it hits release. Thank you!
I will add soon as i can, am just out traveling on vacation full the 29th thx guys!
On Jul 22, 2016 7:50 AM, "Peter Kanev" notifications@github.com wrote:
Hey @sitefinitysteve https://github.com/sitefinitysteve, #501 https://github.com/NativeScript/android-runtime/pull/501 hit the master branch yesterday, you could fetch the latest unstable build from android@next and test away. We'd really appreciate any feedback about the feature, especially if there are any bugs or hints of unexpected behavior. The syntax is as per the issue description, we will have the information appended to our documents once it hits release. Thank you!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NativeScript/android-runtime/issues/442#issuecomment-234524175, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeI6K_aMXkq0o9xJZJIJI7ONEhqMvPAks5qYK6GgaJpZM4IYIgI .
Okay playing with this stuff now per docs on {N} 2.2: http://docs.nativescript.org/runtimes/android/advanced-topics/extend-application-activity
Application seems to load, Activity does not though, unhandled exception saying it can't be found.
https://github.com/sitefinitysteve/nativescript-auth0/blob/master/demo/app/activity.android.js
I haven't even gotten into the multiple interface stuff, trying to get the objects properly extended in JS first. Is something different with the docs vs the 2.2 implimentation?
@sitefinitysteve can you verify that a java MainActivity
file has been generated in java/org/myApp/
?
Hmm nope, doesnt appear to have one
Is it failing to generate, problem in the file itself perhaps? Was just a copy\paste no modifications
@sitefinitysteve turns out that what is causing it is a syntax error in the javascript example. Line 33 should use a colon ( : ) instead of the equals sign. Will see to it that the code example is fixed!
EUGH, man, sorry for that one, does the CLI output any build errors that I would have missed there?
@sitefinitysteve none, as we have disabled the javascript parser's logging indefinitely. It could only be enabled if you went into the js_parser inside build-tools/android-static-.... and enabled it manually.
Apologies for the confusion!
Okay so that worked, trying the TS version...
import {setActivityCallbacks, AndroidActivityCallbacks} from "ui/frame";
setActivityCallbacks appears to be private and TS is pitching a fit
Also I think Application onCreate needs to be public not protected?
Plugin: https://github.com/sitefinitysteve/nativescript-auth0
Something changed in 2.0 where it seems a tns android replaces the NativeScriptActivity.java and NativeScriptApplication.java files every time...
I have no idea how to implement this plugin reliably, and what's this folder now?
Issue 2 outside of that is I have a BroadcastReciever which is where this auth0 activity shoots it's data. https://github.com/sitefinitysteve/nativescript-auth0/blob/master/plugin/platforms/android/NativeScriptActivity.java#L100 But how to I get that data from there into here https://github.com/sitefinitysteve/nativescript-auth0/blob/master/plugin/index.android.js#L13 To return the promise?