How do you detect already registered number with Account Kit? - ios

This is what I used to register the phone number with Account Kit
- (void)viewDidLoad{
[super viewDidLoad];
// initialize Account Kit
if (_accountKit == nil) {
// may also specify AKFResponseTypeAccessToken
_accountKit = [[AKFAccountKit alloc] initWithResponseType:AKFResponseTypeAuthorizationCode];
}
// view controller for resuming login
_pendingLoginViewController = [_accountKit viewControllerForLoginResume];
}
I have implemented Account kit using Swift. I have implemented to register the phone number, but I was wondering if I could detect if the phone is already registered within this the app.

You can check if somebody is already logged in like this:
https://developers.facebook.com/docs/accountkit/ios#loginview
You can store the phone numbers and accountIDs in your own user tables to also verify if somebody has already created an account with that information. You can call the GraphAPI (https://developers.facebook.com/docs/accountkit/graphapi) from your server to check if there have been any updates to those accounts.

Related

Handle credit card added to the Wallet Apple Pay

I am trying to implement the SetUp Apple Pay button on my iOS Xamarin application. I have added button and click handler for it. Then I Use PKPassLibrary.OpenPaymentSetup() to open Wallet. Then if user has successfully added Card into Wallet I need to handle this event via changing "SetUp ApplePay button" to "Pay with Apple Pay". But I can't find working any event handler or something like that.
What I have tried:
private PKPassLibrary _library;
private NSObject _walletNotificationSubscription;
private void OnSetuApplePayClicked(object button, EventArgs args)
{
_library = new PKPassLibrary();
_library.OpenPaymentSetup();
_walletNotificationSubscription = PKPassLibrary.Notifications.ObserveDidChange(_library, HandleEventHandler);
}
void HandleEventHandler(object sender, NSNotificationEventArgs e)
{
_walletNotificationSubscription.Dispose();
ViewModel.UpdateApplePay();
SetButtonVisibility();
}
but it does not work.
P.S.: I guess I maybe observe incorrect events.
Try to use the following code :
if(PKPaymentAuthorizationViewController.CanMakePayments)
{
//the device supports Apple Pay
//check whether the user can make a payment with a bank card ,such as Amex ,MasterCard,Visa,ChinaUnion and so on
NSString[] paymentString = { PKPaymentNetwork.Amex, PKPaymentNetwork.ChinaUnionPay, PKPaymentNetwork.MasterCard, PKPaymentNetwork.Visa };
if(PKPaymentAuthorizationViewController.CanMakePaymentsUsingNetworks(paymentString))
{
//user has added bank card ,do something you want
}
else
{
//user has not added bank card
}
}
else
{
//the device doesn't support Apple Pay
}
There are also some other way of payment ,you can check them in
public static class PKPaymentNetwork
It seems that there is no callbacks or events (at least at Xamarin). So, I had to switch a boolean property of controller when user is sent to the Wallet, and then, when user goes back to app I track "WillEnterForeground" App event where I check whether boolean property is true (if true then user returns from Wallet).
Please note that "ViewWillAppear" does not work in this case, it is not an analogue to the Android's "OnResume".
Also please note that card is activated after 15-20 seconds after adding it to wallet, so I am using "listening cycle" to track card activation.
When card is finally activated I am switching the button from Setup Apple Pay to Pay with Apple Pay.

Checking Firebase current signed-in user via Listener in iOS

I've implement Firebase Authorization to login on my iOS app via Facebook and Google. I'm coding Swift.
When the app starts up I need to check whether a user is already signed-in in order to present the proper ViewController (e.g., if nobody is signed in I present the Login View Controller, otherwise I present the Home View Controller).
If I use the "easy" solution offered by Firebase, meaning
if FIRAuth.auth()?.currentUser != nil {
// User is signed in.
// ...
} else {
// No user is signed in.
// ...
}
So checking if the current user is not nil, it happens exactly what the Firebase guide (https://firebase.google.com/docs/auth/ios/manage-users) alerts might happen meaning
"Note: currentUser might also be nil because the auth object has not finished initializing. If you use a listener to keep track of the user's sign-in status, you don't need to handle this case."
So I would like to implement the listener as suggested in the guide:
handle = FIRAuth.auth()?.addStateDidChangeListener() { (auth, user) in
// ...
}
The listener will handle also intermediate status so that it is triggered when the Auth object is created. Point is I really cannot make it to work properly. Anybody can help me to use this listener in order to check if a user is logged in?
Thanks
I've implemented it like this:
FIRAuth.auth()?.addStateDidChangeListener { auth, user in
if let user = user {
// User is signed in. Show home screen
} else {
// No User is signed in. Show user the login screen
}
}
If you don't need the User object after checking, you can replace if let user = user with a boolean test, like this:
FIRAuth.auth()?.addStateDidChangeListener { auth, user in
if user != nil {
// User is signed in. Show home screen
} else {
// No User is signed in. Show user the login screen
}
}
Where to put the listener (from the comments):
For the cases I used to check if a user is signed in, it was enough to put it at the beginning of viewDidLoad in the specific view controller. But if you have any cases where you need to check every time you enter the specific view controller then it would be better to put it at the beginning of viewDidAppear. But I think in most cases you need to check only once, if the user enters the view
If you're setting up the StateDidChangeListener in application:didFinishLaunchingWithOptions, you'll notice that it fires once when the listener is attached (to set the initial state, which is nil when initialising) and then again once it's finished initialising (potentially not nil). This is intended behaviour, but really impractical if you're setting it up early.
An alternative to using the listener is using NotificationCenter. This will fire once initialisation has finished:
NotificationCenter.default.addObserver(forName: NSNotification.Name.AuthStateDidChange, object: Auth.auth(), queue: nil) { _ in
let user = Auth.auth().currentUser
}

Is there a way to detect revoked permissions through Google APIs?

We're trying to find a way to detect revoked permissions through Google APIs without continuously polling the provider to get status updates. Does Google have any sort of notification system for this (a webhook, etc)?
The most recent post I found regarding this was over 2 years ago.
Look here and search for Check For Permissions
Android Permissions
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.READ_CONTACTS)) {
// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(thisActivity,
new String[]{Manifest.permission.READ_CONTACTS},
MY_PERMISSIONS_REQUEST_READ_CONTACTS);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}

PayPal iOS SDK Sample App

I'm having a play with the PayPal iOS SDK App which I downloaded from https://github.com/paypal/PayPal-iOS-SDK an it works beautifully in sandbox mode BUT I cannot find any property to set for the merchant email address. This is mind boggling to me, as the 'money' has to be sent to the merchant. So the question is, how is this even working?
I'm sure I'm overlooking something. Excuse the stupid question so bear with me.
Cheers.
Using the iOS SDK, the place for this information is in the PayPalConfiguration object -- it is passed as a parameter for all the PayPal provided view controllers.
So for example, in the PayPal demo app:
// Xcode 8.1, Swift 3.0
//MainViewController
//yadda yadda...
var payPalConfig = PayPalConfiguration()
// etc. etc.
override func viewDidLoad() {
super.viewDidLoad()
// Some other stuff
// Set up payPalConfig
payPalConfig.acceptCreditCards = false
payPalConfig.merchantName = "Awesome Shirts, Inc."
payPalConfig.merchantPrivacyPolicyURL = URL(string: "https://www.paypal.com/webapps/mpp/ua/privacy-full")
payPalConfig.merchantUserAgreementURL = URL(string: "https://www.paypal.com/webapps/mpp/ua/useragreement-full")
// blah blah blah
}
This config object is later passed in as:
PayPalPaymentViewController(payment: payment, configuration: payPalConfig, delegate: self)
EDIT: Correction - you're right, there is no property for the merchant's email address, even in the PayPalConfiguration object, just the merchant's name, and merchant's privacy/EULA urls.
However, it should not boggle the mind, as it were, since the merchant has a PayPal [Merchant/Business] account which will receive the money (and they certainly have the merchant's email address), and the merchant needn't expose an email address. The receiver, on the other hand, might not have a PayPal account (yet), so there are properties for the receiver's email address -- e.g., the defaultUserEmail in the configuration object, or the payeeEmail property of the PayPalPayment object (docs).
In IOS SDK, you need to update two files to reflect the environment and merchant client id.
A. ZZAppDelegate.m File
[PayPalMobile initializeWithClientIdsForEnvironments:#{PayPalEnvironmentProduction : #"YOUR_CLIENT_ID_FOR_PRODUCTION",PayPalEnvironmentSandbox : #"YOUR_CLIENT_ID_FOR_SANDBOX"}];
B. ZZMainViewController.m File
define kPayPalEnvironment PayPalEnvironmentNoNetwork
In IOS SDK, you don't need to input merchant's email address, you need to apply one client id in REST APP:https://developer.paypal.com/developer/applications, then place this clent id in above file.

How to send and retrieve real time messages & media files using SupportKit on iOS

I am using Slack with SupportKit v2.9.0. I want to be able to retrieve messages and media files from other users in other channels.
(BOOL) application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[SupportKit initWithSettings:
[SKTSettings settingsWithAppToken:#"eknlh3uw8lrdveknlh3uw8lrdvs49xj29fqahcs49xj29fqahc"]];
[SupportKit setUserFirstName:#"Han" lastName:#"Solo"];
return YES;
}
I am calling SupportKit in my app with:
[SupportKit show];
When the view loads I am able to send and retrieve messages but the name of the user doesn't appear. I would also like to fetch messages from other users of my app into this same conversation.
Update:
I have made the following change
(void) viewDidLoad {
[super viewDidLoad];
[SKTUser currentUser].firstName = #"Doctor";
[SKTUser currentUser].lastName = #"Who";
[[SKTUser currentUser] addProperties:#{ #"nickname" : #"Lil Big Daddy Slim", #"weight" : #650, #"premiumUser" : #YES }];
[SupportKit show];
}
This is what I see in my email:
and this in my app:
But I am still unable to see the name of the user appear in the conversation.
To set the user name and profile you can use
[SKTUser currentUser].firstName = #"Doctor";
[SKTUser currentUser].lastName = #"Who";
[[SKTUser currentUser] addProperties:#{ #"nickname" : #"Lil Big Daddy Slim", #"weight" : #650, #"premiumUser" : #YES }];
See this doc for more details http://docs.supportkit.io/#identifying-your-users
Note that SupportKit conversations are meant to be between an app user and an app maker. Having conversation between two app users is not something that is supported at the moment.
SupportKit cannot be used as a chat client between App users, if that's what you mean. I think what you might be looking for is something along the lines of ChatSecure. However, that won't let you as an App Maker contribute to the conversation between users.

Resources