How do I use ReplayKit's class RPBroadcastActivityViewController? - ios

I want to present RPBroadcastActivityViewController, but fail. The sample code just present a black view.
- (IBAction)displayServiceViewController:(id)sender {
RPBroadcastActivityViewController *rpBroadcastActivityViewController = [[RPBroadcastActivityViewController alloc] init];
[self presentViewController:rpBroadcastActivityViewController animated:YES completion:nil];
}
I hope it's the following effect:
expected

- (IBAction)displayServiceViewController:(id)sender {
[RPBroadcastActivityViewController loadBroadcastActivityViewControllerWithHandler:^(RPBroadcastActivityViewController * _Nullable broadcastActivityViewController, NSError * _Nullable error) {
broadcastActivityViewController.delegate = self;
[self presentViewController:broadcastActivityViewController animated:YES completion:nil];
}];
}

Related

BTDropInController Paypal not open on selection showing "ERROR" in debug area

I'm Using BTDropInController for payment. On 3 Method of payment (Paypal, Venmo, By Card) from Access Control Panel. and Create TokenizationKey also generate.
Now in my Code Firstly import
#import <BraintreeDropIn/BraintreeDropIn.h>
#import <Braintree/BraintreeCore.h>
#import <Braintree/BraintreePayPal.h>
After implement Code dropIn showing but then i click on credit or debit card open another controller to get my card detail But then i click on paypal or venmo nothing happen just show "ERROR" in Debug area
BTDropInController *dropIn = [[BTDropInController alloc] initWithAuthorization:clientTokenOrTokenizationKey request:request handler:^(BTDropInController * _Nonnull controller, BTDropInResult * _Nullable result, NSError * _Nullable error) {
if (error != nil) {
NSLog(#"ERROR");
} else if (result.cancelled) {
NSLog(#"CANCELLED");
[self dismissViewControllerAnimated:YES completion:^{
//
}];
} else {
// Use the BTDropInResult properties to update your UI
// result.paymentOptionType
// result.paymentMethod
// result.paymentIcon
// result.paymentDescription
[self dismissViewControllerAnimated:YES completion:^{
//
}];
}
}];
[self presentViewController:dropIn animated:YES completion:nil];

Diaplay an activity while updating Braintree nuance to server

I am following the following tutorial
https://developers.braintreepayments.com/guides/drop-in/ios/v4
In this I am finding issues when I post the payment nuance to server. The drop in UI remains after I enter the card details. And the options are still enabled so while the payment nuance is in progress user can select another option
Here is my code
BTDropInRequest *request = [[BTDropInRequest alloc] init];
BTDropInController *dropIn = [[BTDropInController alloc] initWithAuthorization:client_TOK request:request handler:^(BTDropInController * _Nonnull controller, BTDropInResult * _Nullable result, NSError * _Nullable error) {
if (error != nil) {
NSLog(#"ERROR");
} else if (result.cancelled) {
NSLog(#"CANCELLED");
[self dismissViewControllerAnimated:YES completion:NULL];
} else {
[self performSelector:#selector(dismiss_BT)
withObject:nil
afterDelay:0.0];
[self postNonceToServer:result.paymentMethod.nonce];
}
}];
[self presentViewController:dropIn animated:YES completion:nil];
In this above image I want to hide the Braintree drop in after I enter the card detail / Paypal
Thanks in advance

Mail Composer Won't Launch From UIPreviewAction

In the view controller for my Peek view of an app I have:
- (NSArray*)previewActionItems {
/
UIPreviewAction *action1 = [UIPreviewAction actionWithTitle:#"Post to Facebook" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
}];
UIPreviewAction *action2 = [UIPreviewAction actionWithTitle:#"Message" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
}];
UIPreviewAction *action3 = [UIPreviewAction actionWithTitle:#"Email" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
[self displayComposerSheet];
}];
/
NSArray *actions = #[action1, action2, action3];
/
return actions;
}
This successfully allows me to pull up a sheet of preview actions after a 3D Touch. displayComposerSheet is:
-(void)displayComposerSheet
{
NSLog(#"Mail Button Pressed");
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:#"Check out this article from Fritch"];
/
NSArray *toRecipients = [NSArray arrayWithObject:#"friend#example.com"];
[picker setToRecipients:toRecipients];
/
NSString *emailBody = self.finalObject.articleImage;
[picker setMessageBody:emailBody isHTML:YES];
[self presentViewController:picker animated:YES completion:nil];
[picker release];
}
However, the mail composer never is presented. Please help.
The issue is probably that the view hierarchy is not normal when the Peek view is shown.
Try using the root view controller to present the picker:
[[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:picker animated:YES completion:nil];

Console warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress

"Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress!"
I'm trying to have my app go to a loading screen upon selecting a picture to upload. This works by, upon selecting a picture, removing the UIImagePickerController scene, adding the Loading scene, and once the upload is complete, removing the Loading scene.
-(void)uploadMessage{
[self dismissViewControllerAnimated:NO completion:nil];
LoadingViewController *loadView = [[LoadingViewController alloc]initWithNibName:#"LoadView" bundle:nil];
[self presentViewController:loadView animated:NO completion:^{
NSData *fileData;
NSString *fileName;
NSLog(#"Image");
fileData = UIImagePNGRepresentation(self.image);
fileName = #"image.png";
PFFile *file = [PFFile fileWithName:fileName data:fileData];
[self.game setObject:file forKey:#"picture"];
[self.game saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if(succeeded){
[self removeAndChangeButtons];
[self dismissViewControllerAnimated:NO completion:nil];
}
}];
}];
}
You can add a function using MBProgressHUD.
- (void) showMessage:(NSString*)message withTitle:(NSString*)title onView:(UIView*)view removeAfter:(NSTimeInterval)delay{
dispatch_async(dispatch_get_main_queue(), ^{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
// Configure for text only and offset down
hud.mode = MBProgressHUDModeText;
hud.labelText = title;
hud.detailsLabelText = message;
hud.margin = 10.f;
hud.yOffset = 0.0f;
hud.removeFromSuperViewOnHide = YES;
[hud hide:YES afterDelay:delay];
});
}
Then in your code when you start the background task, call showMessage and then the upload is done, remove it.
You are dismissing the ViewController twice in your method if it is successful. Obviously, this can't be done. I don't know what exactly what you're trying to achieve, but I think removing the first [self dismissViewControllerAnimated:NO completion:nil] would do the trick.

Spotify EXC_BAD_EXE while second time tap on Login Button after dismiss LoginViewController

Hi i Intigrate SpotifyLib CocoaLibSpotify iOS Library 17-20-26-630 into my Project. I open its SPLoginViewController using Bellow Method:-
-(void)OpenSpotify
{
NSError *error = nil;
[SPSession initializeSharedSessionWithApplicationKey:[NSData dataWithBytes:&g_appkey length:g_appkey_size]
userAgent:#"com.mycomp.spotify"
loadingPolicy:SPAsyncLoadingImmediate
error:&error];
if (error != nil) {
NSLog(#"CocoaLibSpotify init failed: %#", error);
abort();
}
[[SPSession sharedSession] setDelegate:self];
[self performSelector:#selector(showLogin) withObject:nil afterDelay:0.0];
}
-(void)showLogin
{
SPLoginViewController *controller = [SPLoginViewController loginControllerForSession:[SPSession sharedSession]];
controller.allowsCancel = YES;
//controller.view.frame=;
[self presentViewController:controller animated:YES completion:nil];
}
At First time that Appear Spotify Login Screen. After that I tap On Cancel Button, and Try to open again login screen then i got crash EXC_BAD_EXE at this line. sp_error createErrorCode = sp_session_create(&config, &_session);
UPDATE
I Found exet where is got BAD_EXC
in this method
+(void)dispatchToLibSpotifyThread:(dispatch_block_t)block waitUntilDone:(BOOL)wait {
NSLock *waitingLock = nil;
if (wait) waitingLock = [NSLock new];
// Make sure we only queue one thing at a time, and only
// when the runloop is ready for it.
[runloopReadyLock lockWhenCondition:1];
CFRunLoopPerformBlock(libspotify_runloop, kCFRunLoopDefaultMode, ^() {
[waitingLock lock];
if (block) { #autoreleasepool { block(); } }
[waitingLock unlock];
});
if (CFRunLoopIsWaiting(libspotify_runloop)) {
CFRunLoopSourceSignal(libspotify_runloop_source);
CFRunLoopWakeUp(libspotify_runloop);
}
[runloopReadyLock unlock]; // at hear when my debug poin reach after pass this i got bad_exc
if (wait) {
[waitingLock lock];
[waitingLock unlock];
}
}
after doing lots of search i got Solution i check that whether the session already exists then i put if condition like:-
-(void)OpenSpotify
{
SPSession *session = [SPSession sharedSession];
if (!session) {
NSError *error = nil;
[SPSession initializeSharedSessionWithApplicationKey:[NSData dataWithBytes:&g_appkey length:g_appkey_size]
userAgent:#"com.mycomp.spotify"
loadingPolicy:SPAsyncLoadingImmediate
error:&error];
if (error != nil) {
NSLog(#"CocoaLibSpotify init failed: %#", error);
abort();
}
[[SPSession sharedSession] setDelegate:self];
}
[self performSelector:#selector(showLogin) withObject:nil afterDelay:0.0];
}
-(void)showLogin
{
SPLoginViewController *controller = [SPLoginViewController loginControllerForSession:[SPSession sharedSession]];
controller.allowsCancel = YES;
[self presentViewController:controller animated:YES completion:nil];
}
Now no crash and working fine.

Resources