Is there an iOS Native equivalent to the JavaScript client SDK getUserInfo - ibm-mobilefirst

I would like to retrieve my UserIdentity from the server in a Native iOS app, but I see no equivalent to the JavaScript WL.Client.getUserInfo() method in the iOS SDK. Is there a way to do this in iOS?

Perhaps I am using it wrong, but userIdentity() always seems to return nil but I do see valid data in deviceIdenity().
Nonetheless, I decided to implement this in an adapter procedure. After authenticating, the app calls the adapter procedure to fetch the user's profile information before doing anything that will require that profile data.

Related

stripe for expo (react native)

I am working on a mobile app based on expo (react-native) and I need double check if the mobile device supports apple payment. I found a library for stripe payment system #stripe/stripe-react-native and there are files that return method isApplePaySupported - true/false.
I need to use that method without installing that package and I have tried to extract the code which does that validation - I see that declaration of that method in that file node_modules#stripe\stripe-react-native\src\NativeStripeSdk.tsx but I cant find implementation. I mean the code which I can run and get the same response with that isApplePaySupported method.
I do not have big experience in structure of those react modules, but I check all files and can find the only declaration without implementation of that code. Can someone help me?
To rewrite this function yourself, you'll have to write code that interfaces with native components, specifically PassKit.
My recommendation would be to just install that ReactNative SDK from Stripe and use its functions as it does everything you need it to. Especially if you're taking payments with Apple Pay, you need to run the payment through some payment provider, so if you're using Stripe then you need to use Stripe's SDK to actually accept a payment.

How to migrate KeyStore and Keychain key-value pairs generated by and old Cordova-based App to a new React Native based App?

The scenario is quite simple: there is an old App written using Cordova that has to be updated with a new App written from scratch using React Native.
I am not the developer and the maintainer of the App written using Cordova but I could put hands on its source code. I have to rewrite the App and to make a "silently" update, i.e. the new App must no "reset" the data stored on KeyStore (Android) and Keychain (iOS) and it must reuse these data.
When I "update" the App on my test devices I try to access the data generated by the old App using:
react-native-keychain
react-native-secure-key-store
and try to fetch the data, but with no success. The problem is the same on iOS and on Android.
Focussing for the moment on iOS, I use Xcode to build both the Apps. Firstly I build the old version of the App, generate the data and store them on Keychain. Then, I build the new App version, superseding the previous one. I have ensured that on Xcode the Bundle Identifier and the Signing Certificate is the same for both versions. But from the new version of the App I am still unable to access the Keychain. To make the litmus test: I downgrade the App re-building the old version another time, so the old app replaces the new one and in this case from the old App I am able to access the Keychain data.
I am suspecting that, even if the Bundle Identifier, the two Apps are using two different Keychain zones. So, what I have to do in order to be able to access the data stored by the old app from the new one?
The idea I that the user shouldn't be affected by the update of the App, so the Keychain (and the KeyStore) of the old app must be re-used by the new app.
Note: I see that on the old App, the function used to store data in Keychain/KeyStore is:
var ss = new cordova.plugins.SecureStorage(callback)
Note: I have already read this from Apple Developer website, but I suppose it could be not my case, because I can't set the Keychain sharing on the old App, since we are not permitted to release an update of the Cordova-base App. But, however we tried internally to use Sharing Access without success.
In iOS in particular, keychain access is not just tied to the Bundle ID and signing certificate for the app. There is a third element called the "Groups Entitlement" that is designed to allow multiple applications from the same vendor to share keychain access to the same data (imagine separate email and calendar apps sharing a user's login data). Documentation for this mechanism begins here:
https://developer.apple.com/documentation/security/keychain_services/keychain_items/sharing_access_to_keychain_items_among_a_collection_of_apps
The documentation is fairly dense, but despite being intended for multiple apps to share data this also controls an application reading its OWN data. You must ensure that your parameters match the old app precisely or you will not be able to read the old values. You didn't provide the code for the old or new apps, but as an example if the old app had stored values in the Keychain on iOS, you might use react-native-keychain and the following code to read it:
// The "access group" is the Team ID of the OLD APP followed by its full Bundle ID
const accessGroup = 'A12BC3D45.com.company.BundleId';
const accessOptions = {
accessGroup,
accessible: Keychain.ACCESSIBLE.AFTER_FIRST_UNLOCK,
};
const oldCreds = await Keychain.getGenericPassword();
console.debug('Found old credentials', oldCreds); // REMOVE AFTER DEBUGGING
react-native-keychain has several load functions and you may need to experiment with others (such as getInternetCredentials) if your old app stored things differently.

Access `Titanium.App.Properties` in native app

TLDR: Is there is any native way to access the Titanium.App.Properties for both Android and iOS?
I am working on a project where the original app was made with Titanium, and the new updated version is built with Xamarin.
The original developers thought it would be smart to save a Device Token in the Titanium.App.Properties that would be used to access all the users history and purchases.
The device token is not stored anywhere else, so the only way to get to it is through Titanium.App.Properties.
I have the key they used to store the token. So my question is, is there is any native way to access the Titanium.App.Properties for both Android and iOS?
From this doc there is a paragraph:
"Both iOS and Android store app properties in special files on the filesystem. Natively, iOS properties are known as NSUserDefaults, which are stored in .plist files in the application's library directory. Android stores them in standard xml text files at /data/data/com.domainname.appname/shared_prefs/titanium.xml. Titanium provides a uniform means to set and get app properties via the Titanium.App.Properties API."
From this SO question it sounds like a module needs to be used:
"Other iOS applications cannot access these properties and native Android modules must use the Titanium module API TiApplication.getAppProperties method to access these properties."
For Android the Titanium properties are stored in the shared preferences with the path titanium.
ISharedPreferences TitaniumSharedPreferences = CrossCurrentActivity.Current.Activity.GetSharedPreferences("titanium", Android.Content.FileCreationMode.Private);
Then simply use the shared preference to get any property you need.
var userToken = TitaniumSharedPreferences.GetString("UserToken", string.Empty);
For iOS it is simpler, it just uses the NSUserDefaults.
var userToken = NSUserDefaults.StandardUserDefaults.StringForKey("UserToken");
For Android the TiProperties.java file says:
Instantiates the private SharedPreferences collection with the given
name and context.
This means no other Android application will have
access to they keys and values.
You say you use the token to get a history. Is that coming from a server? So is the token send to the server to do the request?
On the other hand: do you own the source code of the Ti app? Create an update that will store the token in some other way.

Application does not own action type

I am working with an application that uses facebook opengraph to post custom objects to a user's wall with a respective custom action. While working in an iOS environment, I am attempting to use the SDK function call:
- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
andParams:(NSMutableDictionary *)params
andHttpMethod:(NSString *)httpMethod
andDelegate:(id <KC_FBRequestDelegate>)delegate;
to post the object. I specified the GraphPath as:
"me/[APP_NAME]:[APP_ACTION]"
and supplied the Params with a correct access token, api_key, and url to the object to be posted on the user's wall.
I then receive the error message:
{"error":{"message":"(#100) Application does not own 479077275455517 action type","type":"OAuthException","code":100}}
in the response from Facebook.
Any insights?
While following a tutorial for iOS SDK integration, I experienced this same issue running tests through the Graph API Explorer, until I finally noticed the sentence on the tutorial: "Go to the Graph API Explorer and select your app from the ''Application'' list."
Essentially I was attempting to post an action to the Graph API Explorer app itself, hence the error, since I do not have privileges to access that app, obviously.
So with that said, most likely somewhere in the setup of the Facebook sdk in your project, you have not entered or incorrectly entered your facebook app id, which produces the error you see.
Application does not own 479077275455517 action type
Is that the name of your action? I doubt it. Rather looks like it might be your app id.
That clearly points to a wrongly build Graph URL. Write it somewhere for debugging, and see what it really contains.
I know this post is old, but I had this same problem and recently resolved it. Be sure to check the FB API call for the correct [APP_NAME]. In my case, I had a test app and a live app, and I had coded the live [APP_NAME] in my FB API call:
FB.api("me/[APP_NAME]:[APP_ACTION]"...
So even though I had the my test app ID in the init, I was calling the prod app namespace in my FB API call.
Yes, [APP NAME] represents the app's namespace.
Hope this helps to clarify for anyone else who runs into this issue.

Is it possible to access text message information through iPhone SDK

I am developing an application where in i want to alert the user if he receives a message from a contact.
I have been struggling for the same yet haven't found any solution to this.
I also wanted to know if the sdk 3.0 allows access to the call history..
There is no access to SMS messages from the application sandbox, and there is no access to call logs from the application sandbox. You can file a feature request with Apple, but I doubt you will see changes to this any time soon. You will not be able to provide any functionality in your app that depends on this information.
Similar question here regarding call history:
Reading call history in iPhone OS
Short answer is, not possible. I do not believe this has changed in 3.0.