Appirater not available in AppDelegate - appirater

I have installed Appirater with Cocoapods however I can't see the class in AppDelegate for some reason. `
import UIKit
import CoreData
import UserNotifications
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// set up Appirater
Appirater.setAppId("...") //DOES NOT RECOGNISE APPIRATER
}
pod file looks like
platform :ios, '8.0'
target 'myapp' do
use_frameworks!
pod 'Appirater'
end
I have used use_frameworks in pod file so I don't think I need a bridging header file. Any help to get this working much appreciated!

You're using frameworks, which means to need to import the framework just like you would any other framework:
import Appirater

Related

How to perform deeplink from widget to parent app in Objective C

My application is a UIKit app (Swift + Objective-C), not a SwiftUI app.
After implementing this new WidgetKit how can I perform deeplink from widget to my app?
Which method in AppDelegate I will get the callback?
Check the code below:
var body: some View {
VStack {
Text(entry.date, style: .time)
.widgetURL(widgetsEntryView.deeplinkURL)
}
}
If I create the project in Swift then I am getting the callback on:
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
}
Tried Link also. Can someone help me to solve this.
Which method in AppDelegate I will get the callback?
You can use application:openURL:options:
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options;

Navigate to Swift UIViewController from Objective-C file

I'm trying to add a native module to a react native project. When the user clicks a button in react native, I want to open the first screen of this native project: https://github.com/AgoraIO/OpenVideoCall-iOS/tree/master/OpenVideoCall
I followed the instructions here https://facebook.github.io/react-native/docs/native-modules-ios to make a native module in Obj-C. I have a class MainViewController which extends UIController. How can I launch or navigate to MainViewController from the objective-C file. I have turned on packages/definesmodules in Xcode build settings, and I try importing "buildtarget-Swift.h" as described here Call Swift function from Objective C class. The import works but MainViewController cannot be found when I try using it.
Here is my code (my Xcode target name is "merge_test" and MainViewController is in merge_test/OpenVideoCall/MainViewController.swift)
:
`
#import "Call.h"
#import <UIKit/UIKit.h>
#import "merge_test-Swift.h"
#implementation Call
RCT_EXPORT_MODULE();
//exports a method to javascript
RCT_EXPORT_METHOD(navigateToExample:(NSString *)name){
MainViewController * vc = [[MainViewController alloc] init];
}
#end
`
I get the error 'Unknown receiver mainviewcontroller' but I'm pretty sure I'm doing more wrong than just that. How do I do this? It was incredibly simple for android, I feel there must be a simple way for ios.
Thanks!

2 app delegates, swift and objective-c

So, I have an app mixed with objective-c and swift, (originally objective-c) And I need to figure out how to have 2 app delegates (one for swift, and the other for objective-c). I've done some research, but found nothing. Please help!
EDIT:
So, I succesfully switched, but now in my delegate, i have this code:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let splitViewController = window!.rootViewController as! UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem
splitViewController.delegate = self
return true
}
But, splitViewController isn't the first vc, so how would I go around fixing it? (I don't know swift very well)
You only need one delegate, do it in Swift. If you create a new app Xcode will use some default code, which as of 8.3.1 is the following:
import UIKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
To answer the comment: it doesn't mess up your code. Remove previous Objective C delegate if needed.

Open iCloud Pics in my app

I have to show all the iCloud picture in my app. So i have to use those photos for further actions.
Is there any framework which i have use to implement the iCloud functionality.
I have checked the various codes and tuts but not able to get the images form the iCloud.
You should use Photos Framework to get access to photos on iCloud. Photos Framework also support photo editing.
For more details you can follow this link - Photos Framework
Perhaps what you are looking for is the UIImagePickerControllerDelegate.
Make your class to inherit UIImagePickerControllerDelegate;
Create a function to pick image from library or camera, initialize a pickerController constant, set delegate to self, get pickerController source type, from camera or library, set allowsEditing to true and present view controller.
Check the code below:
class YourClass: UIViewController, UIImagePickerControllerDelegate {
...
#IBAction func picImage(sender: UIButton) {
let pickerController = UIImagePickerController()
pickerController.delegate = self
pickerController.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
pickerController.allowsEditing = true
self.presentViewController(pickerController, animated: true, completion: nil)
// before user finish picking image, another func has to run, imagePickerController.
}
// After user pick the image, this method will dismiss active view controller.
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
self.dismissViewControllerAnimated(true, completion: nil)
}
}
This is well understood when watching the link tutorial about CoreData, the video is a bit long but worth your time.
My thanks to Jason Rybka, https://www.youtube.com/watch?v=1kCKlv1npw0.
Works for Swift 2.1 / iOS 9.2.
Good luck.

UISplitViewController in Swift navigation from DetailView

I'm trying to create a MasterDetail Application in Swift and it's running well on iOS8 Simulator. However, when I tried it on my iOS 7.1 iPad I got this error:
**Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [UISplitViewController displayModeButtonItem]: unrecognized selector sent to instance**
This is in my AppDelegate.swift file(generated by Xcode, I didn't add anything):
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let splitViewController = self.window!.rootViewController as UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as UINavigationController
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
splitViewController.delegate = self
let masterNavigationController = splitViewController.viewControllers[0] as UINavigationController
let controller = masterNavigationController.topViewController as MasterViewController
controller.managedObjectContext = self.managedObjectContext
return true
}
The problem comes from this line where the left button is created:
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
When I remove this line, it runs on iOS 7 but displays only the DetailView. When I swipe from the left edge the MasterView doesn't appear(on iOS 8 simulator it does) and basically there is no navigation to the MasterView
Had anyone have the same problem?
Thank you!
You can still use deprecated callback function in UISplitViewControllerDelegate to add and remove UIBarButtonItem to your detail view for IOS7 platform. Implement as below in your UISplitViewControllerDelegate
func splitViewController(svc: UISplitViewController, willHideViewController aViewController: UIViewController, withBarButtonItem barButtonItem: UIBarButtonItem, forPopoverController pc: UIPopoverController) {
if !self.respondsToSelector(Selector("displayModeButtonItem")) {
let navigationController = self.viewControllers.last as! UINavigationController
let detailViewController: UIViewController? = navigationController.viewControllers?.last as? UIViewController
barButtonItem.image = UIImage(named: "IC_BackArrow")
detailViewController?.navigationItem.leftBarButtonItem = barButtonItem
} else {
// This callback function is depreciated in IOS8. We use displayModeButtonItem.
}
}
func splitViewController(svc: UISplitViewController, willShowViewController aViewController: UIViewController, invalidatingBarButtonItem barButtonItem: UIBarButtonItem) {
if !self.respondsToSelector(Selector("displayModeButtonItem")) {
let navigationController = self.viewControllers.last as! UINavigationController
let detailViewController: UIViewController? = navigationController.viewControllers?.last as? UIViewController
detailViewController?.navigationItem.leftBarButtonItem = nil
} else {
// This callback function is depreciated in IOS8. We use displayModeButtonItem.
}
}
I had the same issue. displayModeButtonItem is not supported by IOS versions prior to IOS 8. I suspect that you are compiling against IOS 8 but when deploying you are deploying onto an Ipad app with IOS 7.1 installed. I have remedied this situation in my situation (because I can) by installing IOS 8 on the target Ipad. It then worked without issue.