Beaconstac / NearBee-iOS-SDK

Beaconstac NearBee SDK for iOS
https://www.beaconstac.com
MIT License
1 stars 1 forks source link

Add dynamic querystring to beacon's Custom Url? #3

Closed rv888 closed 5 years ago

rv888 commented 5 years ago

This is when a notification is clicked and a custom url is displayed. I'd like to add a dynamic querystring to the custom url as it is loaded. Is this possible?

sachinmobstac commented 5 years ago

Hi @rv888, right now you cannot add the dynamic query string to the custom URL. Can you tell me your use case?

rv888 commented 5 years ago

Our app users will be logged in through the app itself. When they discover a beacon and click the notification, the custom url will appear. On this custom url will be a button to "Save" the offer they see to their account. We need to know who the logged in app user is that is viewing the custom url. My idea was to pass a token or similar as a querystring to the custom url that would signal who the app user is that is viewing the offer. Is there some other way I would be able to know this information at the custom url?

rv888 commented 5 years ago

@sachinmobstac Any ideas for my problem? Thanks

sachinmobstac commented 5 years ago

@rv888, Are you talking about the campaign which is running the Custom URL?

rv888 commented 5 years ago

In the iOS SDK. Option 1) On Custom url display, add a query string to it. Or option 2) if any data inside the app is made available to the custom url view in the sdk. @sachinmobstac

sachinmobstac commented 5 years ago

@rv888, Right now we don't have any method to do it. The standard security recommendation would be to expose a method which will allow you to set the cookies for a particular domain. This way your site can read the values from cookies. Does this sound better?

sachinmobstac commented 5 years ago

@rv888, Is the above fine or do you have any other thoughts?

JoeyBodnar commented 5 years ago

iOS side, how can we set the cookies for the SafariViewController? It doesn't look like there is any exposed instance of the safari view controller for us to work with.

JoeyBodnar commented 5 years ago

actually it looks like it is not possible to set cookies from the iOS app to the SFSafariViewController: https://forums.developer.apple.com/thread/7713

rv888 commented 5 years ago

@sachinmobstac how would we do this based upon what @JoeyBodnar is saying?

sachinmobstac commented 5 years ago

@rv888 @JoeyBodnar, Which authentication mechanism is used in the app to sign in a user?

rv888 commented 5 years ago

@sachinmobstac The app reaches out to a webserver for authentication. A token is returned for the active user inside the app. All actions inside the app uses this token to interact back with the webserver.

sachinmobstac commented 5 years ago

@rv888, Thanks for the information. The SafariViewController and Safari don't share cookies. There is a way to share cookies if you use SFAuthenticationSession. I will discuss with my team and let you know about the implementation.

JoeyBodnar commented 5 years ago

the documentation says SFAuthenticationSession is deprecated (https://developer.apple.com/documentation/safariservices/sfauthenticationsession) and we should use ASWebAuthenticationSession?

sachinmobstac commented 5 years ago

@JoeyBodnar, I know it is deprecated, it is available from iOS 12. We need to support both hence mentioned the older ones. Since you are not using it for authentication we cannot do much with sharing cookies.

rv888 commented 5 years ago

@sachinmobstac Is there no other way to pass a variable through the custom url setup? If we can't do that, then it's going to be a show stopper for us.

JoeyBodnar commented 5 years ago

so would we have to use our own custom WKWebView then, instead of SafariViewController? @sachinmobstac is there a way to easily override the default behavior?

sachinmobstac commented 5 years ago

@rv888 @JoeyBodnar, We will be releasing a new version tomorrow which allows you to add additional parameters before opening the URL.

rv888 commented 5 years ago

@sachinmobstac Thank you! Much appreciated. Please let us know when it's available.

JoeyBodnar commented 5 years ago

ok great! thanks a lot. just let me know when it is released and I will import the new version to the Xcode project.

sachinmobstac commented 5 years ago

@rv888 @JoeyBodnar, We have updated the NearBee (1.1.6) which now has overloaded methods checkAndProcessNearbeeNotification and displayContentOf which lets you add query parameters.

JoeyBodnar commented 5 years ago

alright cool, implementing now

JoeyBodnar commented 5 years ago

@sachinmobstac is it possible to compile the NearBee.framework file in Swift 4.2.1? I am receiving the error "Module compiled with Swift 5.0 cannot be imported by the Swift 4.2.1 compiler." It looks like the other 3 frameworks (EddyStone, SocketIO and Starscream) have been compiled with 4.2.1, and since this is a precompiled framework, I cannot change the Swift Language version in Build settings for it.

JoeyBodnar commented 5 years ago

@sachinmobstac

JoeyBodnar commented 5 years ago

if the compiled swift language version of the frameworks can be synced, please let me know.

sachinmobstac commented 5 years ago

@JoeyBodnar, Is it possible for you to use CocoaPods?

JoeyBodnar commented 5 years ago

@sachinmobstac I just tried cocoapods but it crashes on launch with the error "library not loaded", the same error I received when I tried integrating using cocoapods a few weeks ago. This is the error:

Screen Shot 2019-04-19 at 11 18 02 PM

Also, I have replicated this error in a brand new Xcode project, and pushed it to Github as well: https://github.com/JoeyBodnar/NearbeeCocoapodsTest

if anything in the project looks incorrect just let me know. But it is a brand new Xcode project that I just created and added the nearbee pod to.

My pod file:

platform :ios, '10.0'
target 'TestNearbeeApp' do
    pod 'NearBee'
 end
sachinmobstac commented 5 years ago

@JoeyBodnar,

Please replace with the below pods. I have to look into why it is not properly linking the frameworks.

platform :ios, '10.0'
target 'TestNearbeeApp' do
    pod 'NearBee'
    pod 'EddystoneScanner'
    pod 'Socket.IO-Client-Swift'
 end
JoeyBodnar commented 5 years ago

ok will try now

JoeyBodnar commented 5 years ago

I am receiving the same error message about "library not loaded" in both my project and the test project. I changed my podfile to be exactly as above and ran "pod install".

sachinmobstac commented 5 years ago

You are missing use_frameworks!.

JoeyBodnar commented 5 years ago

alright thank you! it compiles and does not crash on launch now. thanks a lot for the help!

JoeyBodnar commented 5 years ago

for future visitors, my Podfile looks like this:

platform :ios, '10.0'
use_frameworks!
target 'MyApp' do
    pod 'NearBee'
    pod 'EddystoneScanner'
     pod 'Socket.IO-Client-Swift'
 end
JoeyBodnar commented 5 years ago

what is the correct way to use the methods you gave above? Here is my current code:

let isNearBeeNotification = nearBee.checkAndProcessNearbyNotification(response.notification, queryParameters: ["authToken" : authToken])
    if (isNearBeeNotification) {
        completionHandler()
        if let url = response.notification.request.content.userInfo["EddystoneURL"] as? String {
            nearBee.displayContentOf(eddystoneUrl: url, queryParameters: ["authToken" : authToken])
        }
    }

but I was told that this causes the SafariViewControlller to segue to another url and it is just an empty screen. does this look correct?

sachinmobstac commented 5 years ago
// The below should be used only with the Notification
let isNearBeeNotification = nearBee.checkAndProcessNearbyNotification(response.notification, queryParameters: ["authToken" : authToken])
    if (isNearBeeNotification) {
        completionHandler()
    }

// This should be used with the NearBeeBeacon.
let url = nearBeeBeacon.physicalWebEddystoneURL ?? nearBeeBeacon. eddystoneURL
nearBee.displayContentOf(eddystoneUrl: url, queryParameters: ["authToken" : authToken])
JoeyBodnar commented 5 years ago

ok thank you. I will try this tonight with Ryan.

JoeyBodnar commented 5 years ago

Ok thank you a lot for your help! It is working correctly now.