libgdx: Parse.com iOS SDK and RoboVM - ios

I have a app project using libgdx 1.2. I want to add Parse.com push notifications to its iOS and Android builds. No problems with the usual java interface that enables the core app to call into the native platform methods, but I have quite a few problems in understanding how to call Parse.com SDK methods from Java RoboVM code, e.g., assuming NativeMethods were my interface for native methods access, and IOSNatives my iOS RoboVM implementation:
public class IOSNatives implements NativeMethods
{
public void pushNotifications()
{
// how do I write the java code equivalent to this example?
// step 5 here: https://parse.com/tutorials/ios-push-notifications
}
}
I mean, step 5 here: and then I need some hints about steps 1-4 too...
I've already searched SO for similar questions, but the only one I could find is
Is there a way for push notifications in libGDX (Android and iOS projects)?
which doesn't really tell what I need.

In order to work with IOS sdk's written on Objective C, you must use bindings. Binding is wrapper which allows you to call objective C code from java. Fortunately you don't need to write your own binding fot parse, because here is existing one: RoboVM parse binding.
You can look at Sample.java for example of implementation.
You can get more info about bindings and how to add them to your project here

Related

ios swift wrapper in unity related difficulties

i am new to unity.
my aim is to write native wrapper for existing ios sdk.
for a start, i have written sample ios sdk, with just few test methods.
code is written in swift:
https://pastebin.com/auqNutu7
and another file which expose swift functions so that they can matchup with something which unity understands.
https://pastebin.com/rvrSs2aY
and on unity side:
https://pastebin.com/zezmCmKb
i have few queries, which i am not able to figure out.
is this correct way to write:
private static extern void AwesomeSDK_initializeSDK(string name, string apiKey, Action completionHandler);
if you see swift side of code.
i have completion handler/closure in swift method
(https://pastebin.com/auqNutu7)
, how can i relate it to exposed function
(https://pastebin.com/rvrSs2aY)
in swift framework, and also how can i write in unity side
(https://pastebin.com/zezmCmKb).

How to obfuscate Objective C code of Cordova hybrid app?

I have an Ionic v1 / Cordova mobile app and I need to obfuscate all sources. For obfuscation of Javascript I have used https://github.com/javascript-obfuscator/javascript-obfuscator and for Java for Android I have used https://github.com/greybax/cordova-plugin-proguard. As I couldn't find any cordova plugin for obfuscation of Objective C and I decided to use https://github.com/preemptive/PPiOS-Rename.
However, after obfuscation with PPiOS-Rename, there seems to be a problem with obfuscation of cordova plugins and I'm unable to run the app correctly. If I remove the plugins from obfuscation process the app would work but I need to make obfuscated also the code of plugins.
Does anybody have experience with obfuscating the Objective C code of Cordova app please?
Thanks!
The problem that you have is that Cordova relies on a bridge between your app code written in Javascript and the underlying native code in order to function.
By obfuscating all of the Objective C code, the Javascript layer is unaware of this, and can no longer find the native class names it is looking for.
For example, let's suppose you have included cordova-plugin-device in your app.
Its <feature> definition for iOS maps the Device feature name to the CDVDevice class.
Let's suppose your Cordova app calls the plugin method device.getInfo().
This in turn invokes a call to cordova.exec() which calls the Device feature with the getDeviceInfo action.
Under the hood, Cordova looks up Device to find the native class name it's mapped to (CDVDevice) and then on the iOS platform it attempts to call the getDeviceInfo() member function on this class.
However, by running the PPiOS-Rename tool, you have obfuscated both the class name (CDVDevice) and the function name (getDeviceInfo()) so Cordova cannot find the class or function to invoke, so will throw an error.
In this case you'd need to exclude the CDVDevice using the filter option provided by PPiOS-Rename, for example:
ppios-rename --analyze -F 'CDVDevice' /path/to/program.app/program
If you wish to proceed with obfuscating the Objective C layer of your Cordova app, you will have to add exclusions for all of the class and function names which Cordova calls explicitly from the Javascript layer.
This includes any Cordova plugin interface classes in your project, and possibly classes belonging to the Cordova framework itself (as cordova-plugin-proguard does for ProGuard on Android.

importing native iOS framework to nativescript plugin

I'm trying to access an iOS framework class from my NativeScript plugin.
Right now, this plugin only has a SampleClass with a test method that returns a number, but it will change soon. For now, what I'm trying to do is to call the class method from that native framework.
I have seen some examples where the plugin seed extends an iOS base class and creates everything there, but in this case, I want to use a .framework file.
I'm assuming this would be equivalent to use some .aar Android file. In that case, I've seen the call would be made with something like this
var c = java.lang.Class.forName("org.test.plugin.name.MyActivity");
So, I have copied the .framework file to platforms/ios, my question is about how to get this SampleClass method.
Also, I've seen some documentation that recommends the use of CocoaPods. I'm new to iOS development and still don't get this at all, but if my application won't use any native dependency, would this be necessary? Should I need another files? (got a default Info.plist and build.xcconfig)
Thank you for your answers.
Since you are using TypeScript, you have to either declare the classes like,
// iOS
declare var SampleClass;
// Android
declare var org;
then you may access all available packages / classes / methods directly.
// Android
const MyActivity = org.test.plugin.name.MyActivity;
// iOS
SampleClass.new()
If you like intellisense support for these libraries, then you may even generate declaration files for both iOS & Android libraries with the given steps in the docs.

How to wrap existing iOS code in a new Appcelerator module?

This seems like a basic request, but I can't find the answer to it anywhere. I want to wrap some existing iOS code that I wrote, in a Appcelerator module. That's it. Important points:
I am NOT wrapping a pre-existing 3rd party iOS SDK.
I wrote the iOS code being wrapped.
Code is verified as working within xcode.
There are no .a files. There are 2x .h files and 2x .m files though.
There are no UI elements in the iOS code as it is only designed to connect the native bluetooth hardware to the app.
I have created a generic appcelerator iOS module project, built it, and successfully called the generic ID function within my app.
I cannot figure out how to successfully edit the generic module so that it utilizes my code. Every attempt results in it refusing to compile, and it's maddening.
I do not have access to Hyperloop.
Once I can successfully build the wrapped module, I would call an initialization function which triggers a native bluetooth hardware search. Once connected, there are functions within the module to send commands to the hardware and receive data back. This is the official documentation I've followed so far:
http://docs.appcelerator.com/platform/latest/#!/guide/iOS_Module_Quick_Start
That helped me build the blank module, include it in the app, and ensure that it worked by calling the built in test property. From there it stops short of actually telling me what I need to know. These are the closest things I've found so far, while still not being what I need:
http://docs.appcelerator.com/platform/latest/#!/guide/iOS_Module_Project-section-43288810_iOSModuleProject-AddaThird-PartyFramework
appcelerator module for existing ios project sdk
Heck, I still don't even know if I can do this within studio or if I have to edit the generic module in Xcode. Help! :) Many thanks in advance.
so first of all, this is not best practice and will cause possible problems in the future when the SDK changes and your module still relies on outdated core API's.
Regarding your question, you could either create a new component that subclasses the existing class, e.g.
class TiMyModuleListViewProxy : TiUiListViewProxy {
}
and call it with
var myList = MyModule.createListView();
or you write a category to extend the existing API with your own logic, e.g.
#interface TiUIListViewProxy (MyListView)
- (void)setSomethingElse:(id)value;
#end
#implementation TiUIListViewProxy (MyListView)
- (void)setSomethingElse:(id)value
{
// Set the value of "somethingElse" now
}
#end
I would prefer the second option since it matches a better Objective-C code-style, but please still be aware of the possible core-changes that might effect your implementation in the feature. Thanks!

Does Swift support WebRTC?

Our team is in process of electing programming language to develop a new iOS application in which we have to write features to support video conversation.
The backend is written using WebRTC, now we have to decide which language to use in the iPhone app and we prefer Swift in this case.
However, I'm not sure Swift supports WebRTC or not.
My initial research show that we can implement the features using Objective-C. I found an example written in Objective-C which you can find the source code here.
However, I'm not sure about Swift. Does Swift also support WebRTC?
UPDATE 2023
Unfortunately, as of 2023 there still appears to be no completely Swift framework that implements the WebRTC protocol. Although the iOS framework hosted at webrtc.org can be fairly easily used in Swift apps, it is written mostly in objective C.
For those stumbling on this question, who just want to get webRTC running in your app this is still relatively easy using the cocoapod
UPDATE 2016
The easiest way is to get webRTC in your project is to simply install the CocoaPod using the directions at https://cocoapods.org/pods/WebRTC
If you have never used CocoaPods before you will need to first follow this guide: https://guides.cocoapods.org/using/getting-started.html
Original Answer
The simple answer to the question is that there are currently no open source libraries written in Swift conforming to the WebRTC protocol. You can still compile the code from the official WebRTC project into your app. Directions which may not lead to a successful build can be found here: https://webrtc.org/native-code/ios/
Finally, to clarify Omkar Guhilot's answer: Skylink is a company with a closed source SDK that is designed to work only with their paid stun-turn service, and https://github.com/alongubkin/phonertc requires cordova, which may not be ideal for many native ios developers.
Webrtc comes with Objective C interface. I dont think they will move to swift interface anytime soon. But You can always use them via bridging headers. I have written apprtc (webrtc's demo) in swift 2.3 version with help of bridging headers in github link with a description in this blog . I have planned to write 3.0 version and a swift wrappers over it.
Current version of webrtc framework doesn't require any pods or any extra bridging headers.
The framework can be generated by following instructions on this Link :
https://webrtc.github.io/webrtc-org/native-code/ios/
If you follow them correctly you will generate a framework add that framework in your project and follow the webrtc necessary steps and you will have a WEBRTC integrated project.
To know what all steps are necessary follow this link from appear.in
:
https://tech.appear.in/2015/05/25/Getting-started-with-WebRTC-on-iOS/
This will get you to a stage where you will be able to make calls between a browser and any iOS 8+ device
Yes swift supports WebRTC and there is one more library which you can use in swift link:- http://skylink.io/ios/
And the link that you have shared to which is written in Objective C, we should be able to use that as well in swift by creating a Bridging header
Have a look at this as well https://github.com/alongubkin/phonertc
Thanks
Omkar

Resources