Closed addhayam closed 2 years ago
Hi, @addhayam
This is usually due to you are not adding the URL scheme correctly in your Info.plist file. Can you check again if you have followed the instruction here and correct line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)
value is existing under the CFBundleURLSchemes
as an item in the supported URL scheme list?
Hi, @onevcat
In the App settings tab at LINE Developers console we have no field for iOS scheme there is only iOS bundle ID for iOS. Should I still write this line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)
in plist?
Hi,
Sorry for the confusion. The README is a bit outdated now and we are updating it in #56.
There is no need to set it in the LINE Developers console anymore (LINE gateway will automatically set it based on the bundle ID you provided), but you still have to write line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)
in the plist.
@onevcat hi,
i added all the IDs correctly but the above problem still persists (nothing happens after pressing OK/cancel).
do you have any lead that might solve this problem? or could this be a simulator only problem?
@hbali
Ummm, that is strange.
or could this be a simulator only problem?
It won't be. The LINS SDK flutter should bahave in the same way on device and simulator. So there mush be something wrong.
I would suggest try to open the flutter-generated Runner workspace in Xcode, open "SwiftFlutterLineSdkPlugin.swift" and set breakpoints inside both application(_:open:options:)
and application(_:continue:restorationHandler:)
. When clicking the "Open" button, either of the method will be called and the debugger should stop there. If it stops, then you can check if the URL is expected, as below:
It would be helpful if you can paste that URL here so we can investigate further.
If the breakpoint is not hit, it means the flutter is not forwarding the received URL scheme to LINE SDK. Then it would be some other issues.
And before digging into it deeper, you can also try to clone this repo and run the "example" app to see if it works.
@onevcat
so the breakpoint is not hit in SwiftFlutterLineSdkPlugin.swift
however it stops in our own AppDelegate.swift
. Could this be the problem? Our implementation catches the link and it's not forwarded to LineSDK?
By default, Flutter will detect the installed plugins (here, LINE SDK flutter) and do a register for these plugins. Without that, LINE SDK won't have a chance to handle the opened URL. In our demo project (and as well as the default behavior of Flutter), it should look like something below:
If you are customizing the app delegate and not giving the plugin a chance to register itself, you may instead need to call LoginManager.shared.application(application, open: url, options: options)
in the app delegate yourself to forward the received URL to LINE SDK. (Also remember to import LineSDK
if you are going to do that.)
@onevcat
ah yes, this line was there i just wasn't sure what is actually does. the plugin should be registered and the breakpoint stops in the register
method of the plugin.
so when i press "OK" on the Line popup, the breakpoint stops in our method and the url has the correct information as far as I saw. however the breakpoint is not hit in SwiftFlutterLineSdkPlugin.swift
.
our implementation of the URL callback method:
override func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool{
appLaunchLink = url.absoluteString
self.listener?.push(link: url.absoluteString)
return true
}
the system is supposed to call both our and SwiftFlutterLineSdkPlugin's method right?
edit: as a test, i deleted the above method and everything worked fine. so i guess i have to call the LoginManager by myself, right? However there is an error saying
Type of expression is ambiguous without more context
I know this one should be my problem to figure out but do you have any pointers where i should start to solve this?
edit2: found it, the parameter was named app
and i passed as application
lol. the Line popup will return to my app normally 🥳
if there is no problem with this implementation (calling LoginManager by ourselves) then my problem is solved! thank you!
The problem here is that you always return true
in your implementation. When returning true
, it means you are handling this URL and telling the system "it is already handled and do not pass it down any more". So, if it is actually a URL you are not handling (or want other plugin to have a chance to handle), you should instead return false
in your implemetation.
interestingly, if i return false
it doesn't seem to work and the call is not passed to SwiftFlutterLineSdkPlugin
. For now I will stick to calling LoginManager
from our own method
Then maybe it is something else which goes wrong. Anyway, I think adding a LoginManager
invocation in your implemention would be just fine!
I am closing this since the original question was resolved and it is actually not an issue in this project.
Only on iOS: When calling LineSDK.instance.login() and redirect to LINE application, log in and allow the permission, then tap 'OK' button, it's nothing happened.