Implementing iOS specific tasks

Anything libgdx related goes here!

Implementing iOS specific tasks

Postby captainflyaway » Fri Aug 10, 2018 10:13 am

I want to interact with the native calendar app on both Android and iOS.

Android is easy for me (java and android apps before) but on iOS I am unsure.

There are many examples of interacting with the calendar on iOS (but using XCode). Do I just write the code in java and MobiVM does compile it for me or do I need to write the code using XCode which then will get implemented into my app by MobiVM?
captainflyaway
 
Posts: 211
Joined: Mon Feb 20, 2017 7:52 am

Re: Implementing iOS specific tasks

Postby tomski » Fri Aug 10, 2018 11:26 am

You can do either. Its trivial to interface with core ios stuff, because its already bound MobiVM, so you can just use java.
tomski
 
Posts: 830
Joined: Wed Jun 26, 2013 6:06 pm

Re: Implementing iOS specific tasks

Postby captainflyaway » Mon Sep 03, 2018 9:08 pm

Sorry for the late response.
I did every other task on my list but I now still have specific tasks left.

The goal: I want to open the app store/google play store for the user so that he/she can rate my app.

1. On android I implemented everything and it works fine. Of course it is written in java - so it is familiar to me and also libgdx uses java.

2. Now the for me very hard issue: Making in work on iOS.
iOS is using XCode so I do not understand how it is possible to reach my goal. Especially as the xcode syntax is somewhat different from java-

- Should I just look at the xcode code for opening the app store and then translate this code into java and put it in the iOS launcher class ?
- Should I just copy the xcode code in the iOS launcher class and it will compile fine on my mac?
captainflyaway
 
Posts: 211
Joined: Mon Feb 20, 2017 7:52 am

Re: Implementing iOS specific tasks

Postby evilentity » Mon Sep 03, 2018 10:50 pm

You dont need to open xcode for this at all. Something like this will work if you specify correct id
Code: Select all
final String uri = "itms-apps://itunes.apple.com/app/id" + appId + "?action=write-review";
Gdx.net.openURI(uri);
Looking for a freelancer? PM me!
evilentity
 
Posts: 4619
Joined: Wed Aug 24, 2011 11:37 am

Re: Implementing iOS specific tasks

Postby captainflyaway » Tue Sep 04, 2018 8:49 am

thank you, works nicely!

For this task it is actually working without specific code.

But now coming to back to my first question. There is no general code for adding, editing and deleting calendar events.

How would you go with that?
captainflyaway
 
Posts: 211
Joined: Mon Feb 20, 2017 7:52 am

Re: Implementing iOS specific tasks

Postby evilentity » Tue Sep 04, 2018 11:54 am

Probably google how to do that in objc and port it to java. Its not hard.
Looking for a freelancer? PM me!
evilentity
 
Posts: 4619
Joined: Wed Aug 24, 2011 11:37 am

Re: Implementing iOS specific tasks

Postby captainflyaway » Sun Sep 09, 2018 8:31 am

I tried. I tried hard but it I am not able to do it.

I guess I need a little help again.


Code: Select all
  EKEventStore *eventStore = [[EKEventStore alloc] init];
 
    EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
    event.title     =@"My test Event";
 
    NSDateComponents *componentsToSubtract = [[NSDateComponents alloc] init] ;
    [componentsToSubtract setDay:+5];
 
    NSDate *FireDate = [[NSCalendar currentCalendar] dateByAddingComponents:componentsToSubtract toDate:[NSDate date] options:0];
 
    NSDateFormatter *df= [[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-MM-dd"];
    event.startDate =[NSDate date];
    event.endDate   = FireDate;
    event.allDay = YES;
 
    if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)])
    {
        // the selector is available, so we must be on iOS 6 or newer
        [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
            dispatch_async(dispatch_get_main_queue(), ^{
                if (error)
                {
                    // display error message here
                }
                else if (!granted)
                {
                    // display access denied error message here
                }
                else
                {
                    [event setCalendar:[eventStore defaultCalendarForNewEvents]];
                    NSError *err;
                    if ([eventStore saveEvent:event span:EKSpanThisEvent error:&err]) {
                        NSLog(@"Event Added");
                    }else {
                        NSLog(@"%@",[err localizedDescription]);
                    }
                }
            });
        }];
    }
    else
    {
        [event setCalendar:[eventStore defaultCalendarForNewEvents]];
        NSError *err;
        if ([eventStore saveEvent:event span:EKSpanThisEvent error:&err]) {
            NSLog(@"Event Added");
        }else {
            NSLog(@"%@",[err localizedDescription]);
        }
    }


Just the very first line translated (I think)
EKEventStore eventStore = EKEventStore.init();
-> init() has protected access in org.robovm.apple.foundation.NSObject
captainflyaway
 
Posts: 211
Joined: Mon Feb 20, 2017 7:52 am

Re: Implementing iOS specific tasks

Postby evilentity » Sun Sep 09, 2018 9:06 am

Perhaps you should compare how other stuff is implemented. There is no alloc either. Try new EKEventStore().
Looking for a freelancer? PM me!
evilentity
 
Posts: 4619
Joined: Wed Aug 24, 2011 11:37 am

Re: Implementing iOS specific tasks

Postby captainflyaway » Sun Sep 09, 2018 12:17 pm

Has the same issue. Where should I look for other stuff? I am out of ideas honestly
captainflyaway
 
Posts: 211
Joined: Mon Feb 20, 2017 7:52 am

Re: Implementing iOS specific tasks

Postby evilentity » Sun Sep 09, 2018 1:05 pm

Its possible that no one ever bothered to use that thing, looks useless anyway, and its not bound properly. Looks like it should be public.
Looking for a freelancer? PM me!
evilentity
 
Posts: 4619
Joined: Wed Aug 24, 2011 11:37 am

Next

Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot], Google [Bot], Selve and 1 guest