1

First, my app worked fine on iOS 7, since iOS 8 i can't send in-app email thru "MFMailComposeViewController". Message window comes up, only shows subject of the mail and closes within seconds. I found this thread here which describes my problem and now tried to implement the answer from "Joe Blow" https://stackoverflow.com/a/25864182/4061869

But im getting some errors, some sematic and parse issues.

Worst thing according to this part of the workaround:

Of course have this in your Prefix file

#define APP ((AppDelegate *)[[UIApplication sharedApplication] delegate])
// it's worth noting that is the delegate, not the "application"

Leads to this error:

Use of undeclared identifier 'AppDelegate'

Anyone knows where the problem can be? I tried different wordings on 'AppDelegate' according to my filename of the appdelegat.h/.m but nothing helps.

Community
  • 1
  • 1
k0riz0n
  • 43
  • 1
  • 6

1 Answers1

0

You can define the app delegate in whichever ViewController you are working in, by using:

AppNameAppDelegate *APP = [[UIApplication sharedApplication]delegate];

To state the obvious, by AppName I mean the name of your application. Make sure to import the AppDelegate.h into your .m file too.

#import "AppNameAppDelegate.h"

For the record, I am also having the same issue with MFMailComposeViewController,and I have tried the method suggested in the post you linked (creating a global mail composer), but it still won't work for me using the iOS 8 simulator. Apparently it works on a physical device running iOS 8, but I personally cannot confirm that just yet.

Community
  • 1
  • 1
rosshump
  • 370
  • 1
  • 4
  • 21
  • I added the import line to the prefix file and most errors are gone. Now i got a new one with this line `[APP cycleTheGlobalMailComposer];` which says `No visible @interface for 'ITLAppDelegate' declares the selector 'cycleTheGlobalMailComposer'` Do you get any errors while compiling when using the suggested method? – k0riz0n Sep 21 '14 at 10:50
  • If you have your `cycleTheGlobalMailComposer` method in the `AppDelegate.m` file, then you need to call that method from whichever view that you want to bring up the mail composer. You can do this by defining it in the `AppDelegate.h` file by: `- (void)cycleTheGlobalMailComposer;`. Then call this method like: `ITLAppDelegate *callMethod = [[ITLAppDelegate alloc]init]; [callMethod cycleTheGlobalMailComposer];`. This should get rid of any errors. You should set breakpoints when that method gets called so you can see exactly where it's going. This should stop the compile errors. – rosshump Sep 21 '14 at 12:27
  • The `- (void)cycleTheGlobalMailComposer;` is defined in the ITLAppDelegate.m as its written in the tutorial. Now i tried your code `ITLAppDelegate *callMethod = [[ITLAppDelegate alloc]init]; [callMethod cycleTheGlobalMailComposer];` but the error is still `No visible @interface for 'ITLAppDelegate' declares the selector 'cycleTheGlobalMailComposer'`. – k0riz0n Sep 21 '14 at 15:00
  • Hmm, have you declared the `globalMailComposer` in your `ViewController.h` that is using it? `@property (nonatomic, strong) MFMailComposeViewController *globalMailComposer;` - you should do this in both the `AppDelegate.h` and also the `ViewController.h` which is calling the `cycleTheGlobalMailComposer` method, and `@synthesize` it if necessary. – rosshump Sep 21 '14 at 15:57
  • 1
    Hm, no change. But i think i have a solution now. I moved `- (void)cycleTheGlobalMailComposer;`to my ViewController.h and call it with `[self cycleTheGlobalMailComposer];`. Now i can compile without errors an within my app the email window opens with correct data. I try tomorrow if this works on a device too and email sent correctly! Thanks for your help! – k0riz0n Sep 21 '14 at 19:15
  • That's cool man, good job getting it working! So does it work properly in the iOS 8 simulator? With the correct recipient/subject/body etc without throwing any errors? I couldn't get it to work, maybe I'll give it another go if it worked for you :) – rosshump Sep 21 '14 at 20:42