nordnet / cordova-universal-links-plugin

[DEPRECATED] - Cordova plugin to support Universal/Deep Links for iOS/Android.
https://github.com/nordnet/cordova-universal-links-plugin/issues/160
MIT License
349 stars 526 forks source link

Help, I kept getting UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'manifest' of undefined after defining host for universal links #134

Closed blue2609 closed 5 years ago

blue2609 commented 6 years ago

I have no idea what happened, one second the universal links plugin was working just fine and then suddenly now whenever I tried to define a host in the config.xml file I always got this error:

(node:xxxxx) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'manifest' of undefined

as a result of me doing "cordova run android"

However, once I get rid of the

<host name="....."> </host>

section, doing "cordova run android" will build the project with no issue whatsoever. Please help! I don't know what's wrong with this project and the error message is not exactly helping me either.

runezor commented 6 years ago

Exact same issue here.

Did you manage to solve it?

blue2609 commented 6 years ago

Hi mate,

Well yes and no. Yes because I did manage to fix it but no because apparently the problem was not caused by the universal links plugin itself. The problem was the result of me changing the cordova project package name from com.oldName.oldName to com.newName.newName in config.xml <widget> element.

Eventually I had to rename the new package name back to the old one which is com.oldName.oldName to fix the issue. Instead of renaming the package name directly, someone from stackoverflow informed me that to change a cordova project android package name you can simply add the android-packageName attribute inside the config xml <widget> element and specify a new package name for the cordova android project.

Link to my stackoverflow post below right here: https://stackoverflow.com/questions/48029421/change-cordova-project-android-package-name

Cheers mate, hope this helps you a bit.

runezor commented 6 years ago

That's an add odd reason for the error; I don't believe I've made any changes to my widget id

blue2609 commented 6 years ago

@runezor

yeah it's very weird isn't it haha. I honestly have no idea to this day what the error really means. It's not exactly informative as well which makes it harder for us to pinpoint why the error got produced in the first place.

Cheers mate, let me know how it goes yeah?

runezor commented 6 years ago

Sadly that does seem to be a trend. I'm in no position to complain, this being open source and all, but a lot of my recent headaches have been due to confusing or misleading error messages. I hope they'll make it a priority at one point, until then I'll just do my best to avoid them.

Thanks for your help though. I'm currently reconstructing my project, so far without errors. I may just try waiting for a fix, or avoid deep linking all together. Here's hoping that it just works when I get to testing though

blue2609 commented 6 years ago

@runezor

No mate, let's try to fix it haha.

How exactly did you apply the universal links plugin into your project?

Let me start with my project first, for me:

  1. I did cordova plugin add cordova-universal-links-plugin
  2. I went to my <project folder>/config.xml and I added this:
   <universal-links>
        <host name="www.whatever.com">
            <path event="linkFunctionHandler" url="path/to/whatever" />
        </host>
    </universal-links>
  1. in my index.js, inside the onDeviceReady: function() I subscribed the event linkFunctionHandler to a javaScript function named linkFunctionHandler() like this:
   onDeviceReady: function() {
        console.log("Device is ready for work");
        this.receivedEvent('deviceReady');

        universalLinks.subscribe('linkFunctionHandler',linkFunctionHandler);
    },
  1. I made a function called linkFunctionHandler inside index.js such like so:
function linkFunctionHandler(eventData){
    // Do anything you want right here with the eventData object passed
    console.log("The linkFunctionHandler javascript function is executed");
    console.log("The URL which made the app executed this function was" + eventData.url);
}

That's all there is to it mate, that's all I did. Once I did cordova run android after that on my Google Pixel XL (1st Gen) -- Android 8.1, the universal links plugin worked right away.

The outpout on my google chrome web browser console by the linkFunctionHandler() above in this case would be:

The linkFunctionHandler javascript function is executed
The URL which made the app executed this function was http://www.whatever.com/path/to/whatever
runezor commented 6 years ago

With a slight (irrational) fear I'll try following your steps here when I'm at that point in my project rebuilt. Crossing my fingers I'll see that beautiful "build succesful!" this time

blue2609 commented 6 years ago

@runezor

yeah let me know how it goes :)

ramyatrouny commented 6 years ago

hello guys am still facing this issue as well I guess it's all related to universal links and the changed package name, in addition, this error was posted while am trying to integrate facebook plugin using firebase I tried almost everything as well I redeployed this integration from scratch with no success.

did you manage to solve it?

bogacg commented 6 years ago

I'm also facing same issue. Any solution anyone?

ramyatrouny commented 6 years ago

for now, i just removed the link and suddenly everything is working fine, it's extremely weird but for my current implementation it doesn't need them am working on facebook login using firebase

bogacg commented 6 years ago

@mba3gar Which link? You mean one in config.xml ? <host name="....."> </host> part?

ramyatrouny commented 6 years ago

yes the host name= and where you insert the dynamic links parts just remove the whole xml tag and try to build your project `

</universal-links>`
bogacg commented 6 years ago

@mba3gar ok thanks, will try.

bogacg commented 6 years ago

@mba3gar Yes, it seems plugin works, yet it complains about the missing <universal-links> tag.

On the other hand, redirection doesn't give me Facebook login page then it ends on its own and when redirection/popup ends, my app doesn't get credentials, I'll check that out.

ramyatrouny commented 6 years ago

@bogacg consider the following function to login via facebook `loginfacebook(){ let provider = new firebase.auth.FacebookAuthProvider(); console.log(provider);

firebase.auth().signInWithPopup(provider).then(res =>{ console.log(res); });`

replace signin with redirect to sign in with popup

please share with me your firebase version if it's 4.8.1 or 4.8.2

bogacg commented 6 years ago

I've tried it with 4.8.0 & 4.8.2.

When I check console I see this error:

code : "auth/redirect-cancelled-by-user",
message: "The redirect operation has been cancelled by the user before finalizing."

I'll try uninstall and re-install cordova plugins, if no luck then cancel this and use native Facebook/Google plugins.

blue2609 commented 6 years ago

Damn guys I didn't know that many people are getting the same error. I can't help you guys much though because my problem was because I changed the package name, but that's it.

1brunovieira commented 6 years ago

I'm with the same issue, does someone know any workaround?

runezor commented 6 years ago

Apologies for the late response. I tried using popups as a workaround and so far it's working flawlessly. For anyone trying to implement Facebook authentication I'd recommend doing the same, and hope that a fix arrives on this issue later on

ramyatrouny commented 6 years ago

hey, @runezor i just tried to implement it as I mentioned before using popups it works smoothly but the only issue am facing is that whenever the user is successfully logged in he has to close the browser to be able to go back to the application because it does not redirect. did you found a workaround for this?

GeorgeBarnard commented 6 years ago

Same issue here, I'm getting the error and I have not changed my app Id at all. I have tried adding the android-packageName attribute, but it's still giving me the error.

I have been following the firebase-cordova instructions, I don't know if anyone else has the issue using these?

Link to Docs

ramyatrouny commented 6 years ago

@GeorgeBarnard no we are still struggling with the same problem but you better use the following `loginfacebook(){ let provider = new firebase.auth.FacebookAuthProvider(); console.log(provider);

firebase.auth().signInWithPopup(provider).then(res =>{ console.log(res); });`

GeorgeBarnard commented 6 years ago

Yeah, thanks! I tried with pop-ups, and it seems to work, but no information makes it back to the application once the user has logged in. And as you mentioned before, there is no re-direct. I think i'll make do with email auth until a fix has been found.

ramyatrouny commented 6 years ago

@GeorgeBarnard can you please share with me the code once you are done?

GeorgeBarnard commented 6 years ago

Sure, what do you want/need to see? I have been trying to get auth working in-app all day with no luck what-so-ever.

json-alzate commented 6 years ago

Hi guys, like you have many problems with signInWithPopup and signInWithRedirect, but I found this article: https://blog.ionicframework.com/ionic-firebase-facebook-login/ work with signInWithCredential. in theory what it does is get the facebook token with the native ionic plugin and send it to firebase. this afternoon I will try to apply...

donvie commented 6 years ago

Android Studio project detected (node:7052) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'manifest' of undefined (node:7052) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I got that error too, any helps please :-(

bogacg commented 6 years ago

I recommend using native plugins instead of this one.

GeorgeBarnard commented 6 years ago

@bogacg what would you recommend?

ramyatrouny commented 6 years ago

@donvie all these replies because we are all facing the same problem and we are trying to find a workaround for it

@developerjaag in this case you have to fill in the input field of the login with facebook credentials instead of a popup with a redirect so what if you have a 2 step verification enabled? it doesn't work

bogacg commented 6 years ago

@GeorgeBarnard Although process is more tedious, unless this plugin gets fixed we have no other choice it seems. Here are the resources I've read (one warning, some steps might have slightly changed, you'll notice):

Note: I had several issues during build and execution. Depending on your platform/versions you may or may not run into them too. Not subject to this post, and you can find answers with search, just make sure you are searching correct error messages.

GeorgeBarnard commented 6 years ago

@bogacg Thanks for this, informative articles. But you are right, they are fairly tedious. Hopefully a fix for this plugin comes before the need to change.

joughbagh commented 6 years ago

Hey guys.

Making this change in 'cordova-universal-links-plugin/hooks/lib/android/manifestWriter.js' fixed this issue for me: https://github.com/nordnet/cordova-universal-links-plugin/pull/135/commits/b2c5784764225319648e26aa5d3f42ede6d1b289#diff-d5955d9f4d88b42e5efd7a3385be79e9

ramyatrouny commented 6 years ago

@joughbagh I just have a simple question `

<host name="AUTH_DOMAIN" scheme="https">
    <path url="/__/auth/callback"/>
</host>

`

does in the following universal links did you change the path url too? or you kept it the same?

ramyatrouny commented 6 years ago

@joughbagh Thank you, my problem is solved

GeorgeBarnard commented 6 years ago

@joughbagh Amazing thank you, solved this problem for me. Revealed many more in the process.

@mba3gar Have you managed to get auth working in-app?

ramyatrouny commented 6 years ago

@GeorgeBarnard yea sure but i changed few things in my code from Popup to sendRedirect

GeorgeBarnard commented 6 years ago

@mba3gar are you using sign in with facebook/google. I no longer have the manifest error, and the project builds fine, however I have a new error:

this operation is not supported in the environment this application is running on 'location.protocol' must be http, https or chrome-extension and web storage must be enabled

Did you run into anything like this? I know this has gone slightly off topic, but I am at loss.

donvie commented 6 years ago

Thanks guys Its working now :-)

ramyatrouny commented 6 years ago

@GeorgeBarnard just check that you are using Https links in this universal links tag can you please share with me your links?

muralimariyappan commented 6 years ago

@joughbagh thanks man. it worked

GeorgeBarnard commented 6 years ago

@mba3gar Sure, Link.

The blacked out text is simply the App name. Does anything look wrong here?

ramyatrouny commented 6 years ago

@GeorgeBarnard mate, i have the same configuration as well for the universal link tags but the only difference is that am putting this tag directly under author can you please try and update me accordingly

AsmisAlan commented 6 years ago

hey guys, thaks for resolve this error! ... but when i run in android i have this error with the gradle. any solution?

thanks :(.

:app:transformClassesWithDexBuilderForDebug java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files at com.google.common.base.Preconditions.checkState(Preconditions.java:456) at com.android.builder.dexing.ClassFileEntry.withDexExtension(ClassFileEntry.java:64) at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.removeDeletedEntries(DexArchiveBuilderTransform.java:274) at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.transform(DexArchiveBuilderTransform.java:241) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:222) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102) at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173) at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134) at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63) at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88) at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:748)

FAILURE: Build failed with an exception.

BUILD FAILED in 10s

lingoyak commented 6 years ago

@joughbagh Thanks for the info. It worked great with the latest Cordova.

hiepxanh commented 6 years ago

why still someone not merge @joughbagh commit? it really helpful

dorman99 commented 6 years ago

hey guys , i still have the problem here, and i cant find any file in the hooks just read.me, anyone can help me?

gklasen commented 6 years ago

@AsmisAlan sometimes i had "DexArchiveBuilderTransform"-Errors in the past, which could be resolved by using the android platform with version 6.3.0.

hiepxanh commented 6 years ago

@dorman99 here you are image image