StoreKit SKStoreProductViewController in React Native - swift

I'm looking to add StoreKit's SKStoreProductViewController into a React Native project (without using a third-party library). Would like the Store view to show up as a modal when the user taps a "get app" button, which will pass the iTunesID of the product to be displayed.
While RN's documentation explains how to integrate a native view component into a project, I'm not sure I'm understanding how this would translate to a view controller.
While I prefer a solution in objective-c, I can accept a solution that uses Swift.

I was able to parse what I needed from https://github.com/rh389/react-native-store-view. Though I had tried installing the package, it had some breaking issues - but I extracted the key elements and documented them in this Gist:
https://gist.github.com/raffibag/213de82365166e647af975e85076e2ff
In a nutshell:
Pull in native libraries and StoreKit component in new header and Obj-C files in your root app directory (RCTStoreViewManager.m and RCTStoreViewManager.h);
Create a bridge file to connect js methods with the Obj-C / native methods (index.ts);
Pull the js methods into your RN component (Component.js)

Related

Aurelia - How to do composite applications that can be loaded at runtime

What I'm trying to do in Aurelia, is something like Prism is doing in WPF- Composite applications.
So lets say I have a "shell" application that defines the main application layout, then i have modules that I can plugin at run-time. Those modules can be an Aurelia application per se or Aurelia plugin (don't know what to use - need recommendation).
When loaded, the module needs to add it's menu items to the main application menu to expose it's features.
This is a mockup of the application:
Each module can have multiple menu items and can be pretty complex.
I'm using latest Typescript, Aurelia-CLI to create the application, and I'm using the built-in bundler : Aurelia's new built-in bundler.
So What I don't know is:
Those modules/features - what must they be? (Maybe Aurelia Plugins, or another Aurelia application?)
How to load those modules/features at run-time? (like deploy it in some plugins folder and tell the main shell application to load them)
How to modify the main menu and add new menu items from the loaded module?
Please help
Aurelia supports ultra dynamic applications. Also, there have been other community members who have had similar requirements and was able to resolve it. So I think the scenario is possible.
It seems the sub-application can just be a route.How/where to load the route should be determined based on the application URL
Those modules doesn't need to do anything specific, they can just be a normal, plain JS/TS class with lifecycle methods to handle activation/deactivation. I guess that main shell and all sub-applications need to share a common URL, you cannot have more than one router.
There could be a singleton/central store for new route to register information about loaded features, or it can be loaded upfront by a configuration file/metadata file or a database fetch.
Here is a similar question from another community member that I think can help you see how to glue things to https://discourse.aurelia.io/t/dynamicaly-load-routes/1906

Xamarin: MVVMCross info

Adapting the MVVMCross framework in Xamarin crossplatform application development, we have PCL (containing Model and View Model) and View (for each platform) as in here.
a) Where does the Xamarin.mobile (for gaining single set of API access) reside? I think inside the PCL. But, i see different binaries for Xamarin.mobile (eg: Android and IOS), do we put all the Xamarin.mobile library inside the PCL? They all have the same name, won't there be any conflict?
b) Where do we keep codes like accessing bluetooth (not available in Xamarin.mobile)? Using MVVMCross decouples the view and business logic, so do all the codes for creating view items after an event has occured (btn click), reside in the view?
c) Where can we use the conditional compilation adapting MVVMCross? I guess in the Model, but is it only used for file access or can it also be used to show view items (toast message on Android) according to the target platform, by placing it on the PCL?
(Excuses if inappropriate, just gathered some information on MVVMCross and Xamarin.mobile and had some reasonings/confusions in mind)
Thank You!
Regards,
Saurav
a) Where does the Xamarin.mobile (for gaining single set of API access) reside? I think inside the PCL. But, i see different binaries for Xamarin.mobile (eg: Android and IOS), do we put all the Xamarin.mobile library inside the PCL? They all have the same name, won't there be any conflict?
Xamarin.Mobile is not portable code - it can't be called directly from PCLs.
For many Xamarin.Mobile functions (and many, many functions which Xamarin.Mobile does not cover) then MvvmCross provides Plugins - you can see some of that in https://www.nuget.org/packages?q=mvvmcross
For the remaining few methods that X.M has but we haven't already included - e.g. contacts lookup - then you can either:
access the Xamarin.Mobile functions by writing a portable interface (a facade) through which to access them
write a new plugin to implement them
For more on plugins:
see N=8 - adding the location plugin - from the N+1 videos in http://mvvmcross.wordpress.com/
for writing a plugin see https://speakerdeck.com/cirrious/plugins-in-mvvmcross
b) Where do we keep codes like accessing bluetooth (not available in Xamarin.mobile)?
Generally this is done the same way as above. For example, for Bluetooth take a look at the Sphero example:
http://blog.xamarin.com/xamarin-developer-showdown-winning-entries-showcase-xamarin-mobile/
https://github.com/slodge/BallControl/tree/master/Cirrious.Sphero.WorkBench/Plugins/Sphero
Using MVVMCross decouples the view and business logic, so do all the codes for creating view items after an event has occured (btn click), reside in the view?
Yes - if it's a 'view concern', then it belongs in the view (this is the same as any Mvvm code)
c) Where can we use the conditional compilation adapting MVVMCross?
I try not to use 'conditional compilation' including #if and partial classes. Sometimes I'll use it in plugin platform-specific modules, but generally I try to use inheritance or abstraction instead - the reason for this is because I use tools like 'refactoring' and 'unit tests' a lot and conditional compilation simply does not work with these.
For more on the benefits (and disadvantages) of using PCLs rather than file-linking and other project-based techniques, see What is the advantage of using portable class libraries instead of using "Add as Link"?

Create an App within an App

I am being presented with a very interesting project. The task that I must complete is to figure out a way to allow a partner to be involved in an app without giving up their source code. The code will be included in the main bundle of the app so it is not dynamically stored. The partner has a fully functional app that is needed to be ran in a window within the main app at the appropriate time. I know having the partners create a web app would be ideal so it is treated like a webpage but I am more concerned with codes that must be written natively in iOS.
My question is what is the best way to go about solving this? In theory it is like an App within an App. Is there a way if they gave up their .app file I can include this in the bundle and then run it when I catch a certain event? Should I have the partners create their code in a framework and then import into the shell project? What is the best way to approach this problem?
If your 2nd-party doesn't want to provide you with the source code, why doesn't he compile it to object code then let you simply link it to your app?
By the way, at least on official (non-jailbroken) iDevices, apps can't 'embed' or 'open' one another in such a way - you can open an app programmatically if 1. it's a separate app 2. it has a registered special URL associated to its bundle.
Is there a way if they gave up their .app file I can include this in
the bundle and then run it when I catch a certain event?
No, you'll want to have them create a library instead. You can then include that library in your project.
Creating a library is as simple as:
Choose File->New...->Project... in Xcode.
Select the "Cocoa Touch Static Library" project template.
Add your code.
Build.
The result is a static library that you can add to your application(s). The library will contain the compiled code that you added, but doesn't include the source code. The library developer should provide whatever header files are necessary to use the code in the library.
An App within an App is possible however it requires a common data framework that allows one app to reference the same data without confusing the the source of and destination of the data.
Such a framework allows one app to interact with another app referencing the same data.

Migrate custom Facebook util library to Yii framework

I have a facebook app developed in plain PHP, I'm migrating the app to YII framework.
The thing is that I use a class call "utilsFacebook" where I have the object facebook(of the fb sdk) and all the methods that I need to get data from facebook, getUserId, getUserFriendList, etc.
I don't know how to handle all the operations that I do in utilsFacebook with Yii.
Create a controller with the functions of utilsFacebook is the correct think to do?
Every time that I instance the controller would create a new Facebook object, Should I store that object in a SESSION to get a better performance or is a bad idea?
Q. Create a controller with the functions of utilsFacebook is the correct think to do?
Having done a facebook app using yii as the framework, i would recommend you to make this library either a component, or an extension.
But definitely don't put these functions in the controller directly. Whenever a controller needs them call the functions using your custom facebook util class.
Components can be put in the folder: projectrootfolder/protected/components
Extensions can be put in the folder: projectrootfolder/protected/extensions
If you don't believe that either of these make semantic sense, you can always create a new folder within protected, say utils and put the class there. However i think extensions is the best way to go.
Q. Should I store that object in a SESSION to get a better performance or is a bad idea?
I don't think it's necessary to store the object in a session, because there will be no visible performance gain. Further you'll complicate your code unnecessarily.
What i had done was, created an app level component and used this component throughout the app, in any controller.
Example:
In your application's config, protected/config/main.php :
'components'=>array(
'fbHelper'=>array( // gave the component this name
'class'=>'ext.utils.FacebookHelper', // had stored the helper class in extensions/utils folder
'parameter1'='somevalue',
// more parameters
),
// standard yii app components
),
This will allow you to use the component like this: Yii::app()->fbHelper->getFriends();
Take a look at the facebook-opengraph extension, which could help you, on the way.

Including a static library inside a dynamic framework in iOS

I needed to create a framework (which requires a static library) for a project I'm working on. I used this tutorial to create the framework, then copied the static library into the project and it worked.
But, when I dragged the framework to an iOS project, it shows a ton of errors.
`Undefined symbols for architecture i386:"_OBJC_CLASS_$_SomeClassFromTheStaticLibrary",referenced from:_OBJC_CLASS_$_AnotherClass in MyFramework`
What I think is happening is that the iOS project wants to recompile the framework and it cannot, because it can't locate the static library. All errors disappear if I add the static library to the iOS project. This is what I want to avoid.
Basically I want to have the iOS project -> Framework -> Library instead of having the library in both the project and the framework.
I have tried adding the static library as a resource in the framework, but it didn't work.
I doubt this is possible. When you think about what is happening you will see the problem.
The framework is compiled and the static library is processed so that things like extra symbols are stripped out
The app is now compiled and linked against the framework which may or may not have had the symbols that the app is requiring
I did get this to work if ONLY the framework was using the static library (logical) but I can't find a way to share the code across the framework & the app.
If a symbol is hidden (either via Symbols Hidden by Default/GCC_SYMBOLS_PRIVATE_EXTERN being set to YES or __attribute__ ((visibility ("hidden"))) being applied to certain symbols), then that symbol will be available when statically linking the library, but not when dynamically linking the framework.
Ensure that the static library's symbols are not hidden, and you should be able to access them from your app.
I have followed this link to create custom framework. I have static library inside my framework and it works fine with that.
I have copied his steps in my blog for my understanding along with a script to make it universal.