Phonegap record and playback simultaneously - objective-c

I'm currently developing an iPhone/Android application in Phonegap and would like to record audio while playing back another track.
Now I know in Objective-C you can set the audio category to "AVAudioSessionCategoryPlayAndRecord" but since this is Phonegap and not a plain native objective-c app I'm not sure if it's possible for it to work or even where to put it as I think it needs to be in the phonegap core files somewhere>
Does anyone have any experience and/or ideas?

In case anyone else wants to know the answer to this, I managed to sort this issue out by recompiling Cordova/Phonegap (1.7.0 but 2.0 should be similar) with a tweak.
To tweak it I modified CDVSound.m, changing line 482 to
[self.avSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
And re-compiled and then used in my project.

This can be resolved by using a custom Objective C plugin, that sets the category of the AVAudioSession singleton instance to AVAudioSessionCategoryPlayAndRecord.
However there is a bug in the Cordova Media Plugin which complicates things, which can be worked around, if it is acceptable for you to start recording first, and then start playing the media.
If not, I have resolved this issue, and posted an answer here, where you can find more details:
Record and play simultaneously on iOS (Phonegap build)

Related

Appcelerator Titanium and Apple Pay

I am trying to use Apple Pay in a Titanium app. So far I've gotten it to work about a third of the time I run the app, the rest of the time the app crashes. My suspicion is that not adding the apple pay entitlement to the app is causing the crash (unfortunately there is no error message in the console when the app crashes).
Has anyone had any luck getting Apple Pay to work in a Titanium app?
Well, without advertising my Ti.ApplePay module, this might be the easiest way to adopt Apple Pay with Titanium. It supports all major Titanium versions and includes all native API's that are available. Give it a try or use a custom one :-)
I got it working. Here is a gist of the code in my module: https://gist.github.com/zach-babb-moovel/bd4172454cf54a178855e76ca5dd1f48. The key was wrapping the PKPaymentRequest and subsequent PKPaymentAuthorizationViewController parts in a dispatch_async call. You'll also have to make sure all your profiles are set up correctly and that you use a custom Entitlements.plist file for your Titanium project. Check out the Entitlements.plist here: https://github.com/hansemannn/applepaydemo/blob/master/Entitlements.plist for what it should look like.

iOS Push Notification/Framework issue

I've been checking around the net to find some information or source code to achieve this. The thing is, that the Application I am developing uses a custom framework we are also developing. And our customer wants to add Push Notification support for the App.
But he wants the Framework we created to handle the Push Notifications (rather than the App). The following graph will explain a bit better the situation:
The problem is that the AppDelegate seems to be the only handling the Notifications from the OS, so the only solution I can think of is the App forwarding the notifications that come from the OS to the Framework. Any ideas or thoughts? Am I missing something?
Txs in advance
You will have to forward the calls. It should only require a few lines of code added to the appdelegate to interface with your framework though.
You could also do a hacky and more advanced approach where you swamp the IMP's of the AppDelegate methods and forward them through your framework. Just make sure you call the original imp once you're framework has done what it needs to. I wouldn't recommend this approach though as it may not remain stable for future ios versions.
Forwarding the calls is the way to go in my opinion.

Use phonegap or go native?

I'm about to make an application for ipad that has the following specifications:
download JSON (or xml) from server
download short audiofiles from server (locations are in the JSON from above)
save these to the iPad for offline use.
based on these files the user gets to do some exercises
user progress/results need to be saved to the device so they can continue where they left off the next time they launch the app.
My question: Can this be done with only html/css/jquery Phonegap? Or should I go native and make this all in Objective-C? Or can I combine phonegap and Objective-C?
Now I'd like to know how I can save a json file on the device for offline use.
Also I'd like to know how to download audio (or images or whatever) and save those to the device.
This can be done with PhoneGap/Cordova and its HTML5 approach.
If it is iPad only, then go native.
Your app's high level requirements do not sound too complicated. For more complex apps always consider that facebook just went native for iOS because of their performance issues. In the end, this may be the way to go for a number of apps. PhoneGap or other HTML5 or cross compiling approaches for 1000+ devices plus native solutions for the market leaders.
It depends on what level UX your are aiming for and how you think your app may expand in the future.
If you need full control over the user experience, then you will need to go native. All the physics involved in scrolling/swiping will be done for you. How much content will you have? if it's thousands of items then again native will offer the best performance. You can also perform certain tasks on background threads (my app did image compression and resizing before uploading the image, for example).
Otherwise - if you just want to get something out quick, go with phonegap.
*I speak as a developer who started out with Phonegap but went Native for performance reasons. Others may have had better experiences.
Comparing application build in native Objective-C with applications build with Webtool like PhoneGap, in terms of being fast, Objective-C apps always win, but in terms of building it fast with zero knowledge of Objective-C Web apps win.
If you have knowledge of Objective-C, in my opinion go with native Objective-C app, else do it with PhoneGap.
BTW, those functionality mentioned in your question can be done with both.

Phonegap iOS custom context menu

I'm developing a phonegap app for iOS, an would like to insert a new option in the context menu that shows up after selecting text. I had a look to several post which are quite related, and almost all of them led to this link. I followed the instructions of that example, but couldn't make it work, due to my lack of experience with Objective-c. Even so, I'm not sure if that one is a valid solution using Cordova/Phonegap, at least without hacking the framework.
Has somebody accomplished this task?

Embeding streaming player inside my app IOS

I'm trying to create an iPhone app which plays local radio station in my district. I found this player to work best for me :
https://github.com/DigitalDJ/AudioStreamer
When testing it against my requirements it did the best without any doubt.
I thought I'll use this players API and it should be straightforward(not really for a newbie). How exactly I do that is where I'm stuck now. Because when I run the player original project it runs smooth, but when I copy code inside Classes to my app, this is what happens :
Ok, I've been developing some apps(test apps) for two weeks maybe and I lack experience.
How do you usually embed/import other projects code into your code and user the other codes api?
EDIT
So per Sunil Pandey answer, this cannot be run using IOS SDK version 5.0?
EDIT 2 :
I feel like I'm really close now, have this one issue :
Receiver 'AudioStreamer' for instance message is a forward declaration
It's declared in my h file. as AudioStreamer *streamer
As said Sunil Pandey, ARC mecanism is enabled for your project. With ARC, your project require at least iOS4 on the phone.
I would suggest you to disable ARC for the file you imported from the third party librairy. So you can keep using ARC in your own code (this mean, you never use retain, release, autorelease).
To disable ARC for each file of your AudioStreamer library, refer to How can I disable ARC for a single file in a project?
You must have implemented ARC inside your project. that's why it is giving you this error.
If you are using ARC then only way to use this project library is to create a static library of your AudioStreamer lib and then import it inside your app
Or
If you don't want to use ARC inside your app then you can turn it off by following method
select your target -> Build Setting -> Apple LLVM Compiler 3.0 - Language
set Objective c Automatic Reference Counting to NO