Git Product home page Git Product logo

react-native-add-calendar-event's Introduction

Maintenance notice

The author of this package does not use it in production and does not have free time to maintain it. There are open issues that the author does not plan to fix. PRs may or may not be accepted. If you need help or do any development on the package, you can hire the author. You can also maintain your own fork.

react-native-add-calendar-event

This package alows you to start an activity (Android) or show a modal window (iOS) for adding, viewing or editing events in device's calendar. Through a promise, you can find out if a new event was added and get its ID, or if it was removed. The functionality is provided through native modules and won't therefore work with Expo.

For managing calendar events without the UI for user to interact with, see react-native-calendar-events.

Getting started

npm install react-native-add-calendar-event --save

or

yarn add react-native-add-calendar-event

Permissions

You'll also need to install and setup react-native-permissions, or similar, to request calendar permissions for your app.

Expo Support

This package is not available in the Expo Go app. Learn how you can use it with custom dev clients.

Mostly automatic installation

  1. (only RN < 0.60) react-native link react-native-add-calendar-event

(only RN >= 0.60) run pod install in the ios folder

  1. add NSCalendarsWriteOnlyAccessUsageDescription or NSCalendarsFullAccessUsageDescription (for edit/view access) to your Info.plist file. The string value associated with the key will be used when asking user for calendar permission.

  2. rebuild your project

iOS note for RN < 0.60: If you use pods, react-native link will probably add the podspec to your podfile, in which case you need to run pod install. If not, please verify that the library is under link binary with libraries in the build settings in Xcode (see manual installation notes).

Quick example

See the example folder for a demo app.

Using react-native-permissions to request calendar permission before creating a calendar event.

import { Platform } from 'react-native';
import * as AddCalendarEvent from 'react-native-add-calendar-event';
import * as Permissions from 'react-native-permissions';


const eventConfig = {
  title,
  // and other options
};

Permissions.request(
  Platform.select({
    ios: Permissions.PERMISSIONS.IOS.CALENDARS_WRITE_ONLY,
    android: Permissions.PERMISSIONS.ANDROID.WRITE_CALENDAR,
  })
)
  .then(result => {
    if (result !== Permissions.RESULTS.GRANTED) {
      throw new Error(`No permission: ${result}`);
    }
    return AddCalendarEvent.presentEventCreatingDialog(eventConfig)
  })
  .then((eventInfo: { calendarItemIdentifier: string, eventIdentifier: string }) => {
    // handle success - receives an object with `calendarItemIdentifier` and `eventIdentifier` keys, both of type string.
    // These are two different identifiers on iOS.
    // On Android, where they are both equal and represent the event id, also strings.
    // when { action: 'CANCELED' } is returned, the dialog was dismissed
    console.warn(JSON.stringify(eventInfo));
  })
  .catch((error: string) => {
    // handle error such as when user rejected permissions
    console.warn(error);
  });

Creating an event

call presentEventCreatingDialog(eventConfig)

eventConfig object:

Property Value Note
title String
startDate String in UTC, format: 'YYYY-MM-DDTHH:mm:ss.SSSZ'
endDate String in UTC, format: 'YYYY-MM-DDTHH:mm:ss.SSSZ'
location String
allDay boolean
url String iOS only
notes String The notes (iOS) or description (Android) associated with the event.
navigationBarIOS Object config object for the navbar, see below

The dates passed to this module are strings. If you use moment, you may get the right format via momentInUTC.format('YYYY-MM-DDTHH:mm:ss.SSS[Z]') the string may look eg. like this: '2017-09-25T08:00:00.000Z'.

More options can be easily added, PRs are welcome!

Editing an event

call presentEventEditingDialog(eventConfig)

eventConfig object:

Property Value Note
eventId String Id of edited event.
useEditIntent boolean Android only, see description below.

useEditIntent: ACTION_EDIT should work for editing events, according to android docs but this doesn't always seem to be the case as reported in the bug tracker. This option leaves the choice up to you. By default, the module will use ACTION_VIEW which will only show the event, but from there it is easy for the user to tap the edit button and make changes.

Viewing an event

call presentEventViewingDialog(eventConfig)

eventConfig object:

Property Value Note
eventId String Id of edited event.
allowsEditing boolean iOS only; docs
allowsCalendarPreview boolean iOS only; docs

Interpreting the results

The aforementioned functions all return a promise that resolves with information about what happened or rejects with an error.

Due to the differences in the underlying native apis, it is not trivial to come up with a unified interface that could be exposed to JS and the module therefore returns slightly different results on each platform (we can do better though, PRs are welcome!). The rules are:

  • presentEventCreatingDialog
situation result on both platforms
event is created { action: 'SAVED', eventIdentifier: string, calendarItemIdentifier: string }
event creation is cancelled { action: 'CANCELED' }
  • presentEventEditingDialog
situation result on iOS result on Android
event is edited { action: 'SAVED', eventIdentifier: string, calendarItemIdentifier: string } { action: 'CANCELED' }
event editing is cancelled { action: 'CANCELED' } { action: 'CANCELED' }
event is deleted { action: 'DELETED' } { action: 'DELETED' }
  • presentEventViewingDialog

On Android, this will lead to same situation as calling presentEventEditingDialog; the following table describes iOS only:

situation result on iOS
event modal is dismissed { action: 'DONE' }
user responded to and saved a pending event invitation { action: 'RESPONDED' }
event is deleted { action: 'DELETED' }

Configuring the navigation bar (iOS only)

The navigation bar appearance for all calls can be customized by providing a navigationBarIOS object in the config. The object has the following shape:

navigationBarIOS: {
  tintColor: string,
  barTintColor: string,
  backgroundColor: string,
  translucent: boolean,
  titleColor: string,
}

Please see the docs on tintColor, barTintColor, backgroundColor, translucent, titleTextAttributes (NSForegroundColorAttributeName)

Exported constants

Please note that SAVED, CANCELED, DELETED, DONE and RESPONDED constants are exported from the module. The constants are borrowed from iOS and are covered in EKEventViewAction docs and EKEventEditViewAction docs.

Note on the Date JS Object

It is recommended to not rely on the standard Date object and instead use some third party library for dealing with dates, such as moment.js because JavaScriptCore (which is used to run react-native on devices) handles dates differently from V8 (which is used when debugging, when the code runs on your computer).

Changing the language of the iOS dialog

see StackOverflow answer

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-add-calendar-event and add RNAddCalendarEvent.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNAddCalendarEvent.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.vonovak.AddCalendarEventPackage; to the imports at the top of the file
  • Add new AddCalendarEventPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-add-calendar-event'
    project(':react-native-add-calendar-event').projectDir = new File(rootProject.projectDir,   '../node_modules/react-native-add-calendar-event/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-add-calendar-event')
    

react-native-add-calendar-event's People

Contributors

bfanger avatar copser avatar dependabot[bot] avatar jmeiss avatar jpeer264 avatar lon-io avatar luancurti avatar manduro avatar minishlink avatar mordaha avatar mrloh avatar mvanroon avatar pablocarrillo avatar peretz30 avatar sebzinck avatar shrutic avatar uncledent avatar vonovak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-native-add-calendar-event's Issues

Manual installation

Just to clarify the names in the manual for faster finding:

It seems to be libRNAddCalendarEvent.a and RNAddCalendarEvent.xcodeproj

(right now it says libAddCalendarEvent.a and AddCalendarEvent.xcodeproj in the manual)

Great Project !!

Getting "unparseable date" on Android

Hi there,

I'm using RN 0.46.1 on an Android 7.0 and react-native-add-calendar-event 0.2.0

The code below works fine on iPhone:

const eventConfig = {
  title: "Title here",
  startDate: "2017-09-25T08:00:00.000Z",
  endDate: "2017-09-25T09:00:00.000Z",
  location: "Place name"
};

AddCalendarEvent.presentNewCalendarEventDialog(eventConfig)
  .then(eventId => {
      console.warn(eventId);
  })
  .catch(error => {
    console.warn(error);
  });

But fails on Android. Logcat outputs the following line (the catch block yields the same as well):

08-29 12:41:20.731 31223  5763 W ReactNativeJS: { [Error: Unparseable date: "2017-09-25T08:00:00.000Z"] framesToPop: 1, code: 'AddCalendarEvent' }

I've also tried by wrapping the JSON date string with a new Date(...) constructor, but no luck so far.

Is anyone facing the same issue?
Thank you

Exception android.database.CursorIndexOutOfBoundsException

I found a crash issue on client's phone by firebase crash report.
Do you have any idea about this? thanks you

Exception android.database.CursorIndexOutOfBoundsException: Requested column: -1, # of columns: 1
android.database.MatrixCursor.get (MatrixCursor.java:66)
android.database.MatrixCursor.getLong (MatrixCursor.java:277)
com.vonovak.AddCalendarEventModule.extractLastEventId (AddCalendarEventModule.java:136)
com.vonovak.AddCalendarEventModule.onLoadFinished (AddCalendarEventModule.java:119)
android.app.LoaderManagerImpl$LoaderInfo.callOnLoadFinished (LoaderManager.java:489)
android.app.LoaderManagerImpl$LoaderInfo.onLoadComplete (LoaderManager.java:457)
android.content.Loader.deliverResult (Loader.java:144)
android.content.CursorLoader.deliverResult (CursorLoader.java:109)
android.content.CursorLoader.deliverResult (CursorLoader.java:97)
android.content.AsyncTaskLoader.dispatchOnLoadComplete (AsyncTaskLoader.java:265)
android.content.AsyncTaskLoader$LoadTask.onPostExecute (AsyncTaskLoader.java:92)
android.os.AsyncTask.finish (AsyncTask.java:667)
android.os.AsyncTask.-wrap1 (AsyncTask.java)
android.os.AsyncTask$InternalHandler.handleMessage (AsyncTask.java:684)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:185)
android.app.ActivityThread.main (ActivityThread.java:6504)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:916)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:806)

Utils.java:8: error: package android.support.annotation does not exist

Hello, first of all thanks for your work on this lib.

When running "react-native run-android" i got these errors :

Version:
"react-native": "0.57.3"
"react-native-add-calendar-event": "^2.3.1"

/Users/jeremy/Documents/Dev/MYAPP/node_modules/react-native-add-calendar-event/android/src/main/java/com/vonovak/Utils.java:8: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
/Users/jeremy/Documents/Dev/MYAPP/node_modules/react-native-add-calendar-event/android/src/main/java/com/vonovak/AddCalendarEventModule.java:14: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
/Users/jeremy/Documents/Dev/MYAPP/node_modules/react-native-add-calendar-event/android/src/main/java/com/vonovak/Utils.java:25: error: cannot find symbol
  @Nullable
   ^
  symbol:   class Nullable
  location: class Utils
/Users/jeremy/Documents/Dev/MYAPP/node_modules/react-native-add-calendar-event/android/src/main/java/com/vonovak/AddCalendarEventModule.java:212: error: cannot find symbol
    private void returnResultBackToJS(@Nullable Long eventPostId) {
                                       ^
  symbol:   class Nullable
  location: class AddCalendarEventModule
Note: /Users/jeremy/Documents/Dev/MYAPP/node_modules/react-native-add-calendar-event/android/src/main/java/com/vonovak/AddCalendarEventModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/jeremy/Documents/Dev/MYAPP/node_modules/react-native-add-calendar-event/android/src/main/java/com/vonovak/AddCalendarEventModule.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-add-calendar-event:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

gradle-wrapper.properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
# distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
# distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

android/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.0")

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

subprojects { project -> 
  afterEvaluate {
        if((project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        
    }
}




// task wrapper(type: Wrapper) {
//     gradleVersion = '4.4'
//     distributionUrl = distributionUrl.replace("bin", "all")
// }

android/app/build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.app.myapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 5
        versionName "3.5.4"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        multiDexEnabled true
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

subprojects {
    project.configurations.all {
        afterEvaluate {project ->
            if (project.hasProperty("android")) {
                android {
                    compileSdkVersion rootProject.ext.compileSdkVersion
                    buildToolsVersion rootProject.ext.buildToolsVersion
                }
            }
        }
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

dependencies {
    compile project(':react-native-code-push')
    compile project(':react-native-webrtc')
    compile project(':react-native-image-picker')
    compile project(':react-native-add-calendar-event')
    compile project(':react-native-contacts')
    compile project(':react-native-device-info')
    compile project(':react-native-svg')
    compile project(':react-native-incall-manager')
    compile project(':react-native-cookies')
    compile project(':react-native-webview-bridge')
    // implementation project(':WebRTCModule')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

project.afterEvaluate {
    apply from: '../../node_modules/react-native-zss-rich-text-editor/htmlCopy.gradle';
    copyEditorHtmlToAppAssets(file('../../node_modules/react-native-zss-rich-text-editor'))
}

gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

MYAPP_RELEASE_STORE_FILE=androidkey.jks
MYAPP_RELEASE_KEY_ALIAS=androidkey
MYAPP_RELEASE_STORE_PASSWORD=XXXX
MYAPP_RELEASE_KEY_PASSWORD=XXXX

do you have any idea to fix these errors?

Android app crash: when discard event and back to my app

If the event save to Calendar -> its work fine. But when I discard not save and back to my app -> Crash. Please send to me any solutions or fix soon if its a bug. Thanks so much.

"react-native": "0.57.1", "react-native-add-calendar-event": "^2.2.0",

ADB LOGCAT:

12-12 13:56:55.082 1485 1530 E AudioFlinger: createRecordTrack_l() initCheck failed -12; no control block? 12-12 13:56:55.082 2244 4525 E AudioRecord: AudioFlinger could not create record track, status: -12 12-12 13:56:55.083 2244 4525 E AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -12. 12-12 13:56:55.083 2244 4525 E android.media.AudioRecord: Error code -20 when initializing native AudioRecord object. 12-12 13:56:55.083 2244 4525 I MicrophoneInputStream: mic_started com.google.android.apps.gsa.staticplugins.aa.c@9920bf4 12-12 13:56:55.087 2244 4525 I MicrophoneInputStream: mic_close com.google.android.apps.gsa.staticplugins.aa.c@9920bf4 12-12 13:56:55.087 2244 4995 I MicroRecognitionRunner: Detection finished 12-12 13:56:55.087 2244 4995 W ErrorReporter: reportError [type: 211, code: 524300]: Error reading from input stream 12-12 13:56:55.087 2244 4995 W ErrorProcessor: onFatalError, processing error from engine(4) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: com.google.android.apps.gsa.shared.speech.b.g: Error reading from input stream 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at com.google.android.apps.gsa.staticplugins.recognizer.j.a.a(SourceFile:28) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at com.google.android.apps.gsa.staticplugins.recognizer.j.b.run(SourceFile:15) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at java.util.concurrent.FutureTask.run(FutureTask.java:266) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at java.util.concurrent.FutureTask.run(FutureTask.java:266) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at com.google.android.apps.gsa.shared.util.concurrent.a.ag.run(Unknown Source:4) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at com.google.android.apps.gsa.shared.util.concurrent.a.bo.run(SourceFile:4) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at com.google.android.apps.gsa.shared.util.concurrent.a.bo.run(SourceFile:4) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at java.lang.Thread.run(Thread.java:764) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at com.google.android.apps.gsa.shared.util.concurrent.a.ak.run(SourceFile:6) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space. 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at com.google.android.apps.gsa.speech.audio.Tee.f(SourceFile:103) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at com.google.android.apps.gsa.speech.audio.au.read(SourceFile:2) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at java.io.InputStream.read(InputStream.java:101) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at com.google.android.apps.gsa.speech.audio.ao.run(SourceFile:18) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: at com.google.android.apps.gsa.speech.audio.an.run(SourceFile:2) 12-12 13:56:55.087 2244 4995 W ErrorProcessor: ... 11 more 12-12 13:56:55.087 2244 4995 I AudioController: internalShutdown

CODE Sample:

`const eventConfig = {
title: 'New event appointment',
startDate: moment(new Date(), "YYYY-MM-DDTHH:mm:ss.SSSZ"),
endDate: moment(new Date(), "YYYY-MM-DDTHH:mm:ss.SSSZ").add(1, 'days'),
location: '156 xa dan 2 ha noi',
allDay: true,
url: 'https://appointments.se',
notes: 'note nhe',
// and other options
};

  //await RNCalendarEvents.authorizeEventStore()
  AddCalendarEvent.presentEventCreatingDialog(eventConfig)
      .then( async (eventInfo: { calendarItemIdentifier: string, eventIdentifier: string }) => {
          // handle success - receives an object with `calendarItemIdentifier` and `eventIdentifier` keys, both of type string.
          // These are two different identifiers on iOS.
          // On Android, where they are both equal and represent the event id, also strings.
          // when { action: 'CANCELLED' } is returned, the dialog was dismissed
          //YellowBox.js:67 {"action":"SAVED","calendarItemIdentifier":"56","eventIdentifier":"56"}
          console.log('eventInfo:',eventInfo, eventInfo.eventIdentifier);
      })
      .catch((error: string) => {
          // handle error such as when user rejected permissions
          console.warn(error);
      });`

Change language

Looks like the event screen is hard coded in English, I've tried to change language of the phone (IOS) settings without success. Is there any other setting on xCode we have to set?

Cannot read property 'presentNewEventDialog' of undefined

simulator screen shot - iphone 6 - 2018-02-19 at 12 56 41

in my code i import import * as AddCalendarEvent from 'react-native-add-calendar-event';

and using (for example)

const CalendarButton = () => (
  <TextButton onPress={() => {
    AddCalendarEvent.presentNewCalendarEventDialog({})
      .then(eventId => {
        //handle success (receives event id) or dismissing the modal (receives false)
        if (eventId) {
          console.warn(eventId);
        } else {
          console.warn('dismissed');
        }
      })
      .catch((error: string) => {
        // handle error such as when user rejected permissions
        console.warn(error);
    });

  }} text="Calendar" />
);

and I get the attached error. I have linked and followed your instructions. Any ideas? Thanks

Android error: The specified project directory ‘../node_modules/react-native-add-calendar-event/example/EventDemo/android' does not exist.

Getting Android error: The specified project directory ‘../node_modules/react-native-add-calendar-event/example/EventDemo/android' does not exist, IOS works fine.

Below is my project versions & troubleshooting done:

Version:
Android Studio: 3.4.2
Node: v12.4.0
Npm: 6.9.0

"react": "16.5.0",
"react-native": "0.57.1",
"react-native-add-calendar-event": "^2.3.0",

 fsevents: "2.0.7"

TS:

  1. Deleted .idea folder then reopening project. 
  2. Uninstall/reinstall react-native-add-calendar-event
  3. Uninstall/reinstall fsevents
  4. Uninstall node_modules / npm install
  5. Invalidate Caches / Restart

report from production :)

  1. IOS - Case: You have 1 or more shared calendars (in your Calendar App). When you try to select another calendar (than default) when creating event - app crashes.
    It is because app wanna access to Contacts (?) and needs description in NSContactsUsageDescription to ask such permissions.
    After adding NSContactsUsageDescription, app (lib) doesn't crash and function normally after asking permission in ether granted or not granted result of request.

  2. IOS - without NSContactsUsageDescription (and without asking about access to Contacts) - when create event dialog popped it is possible to add members to created event from your Contacts.
    With NSContactsUsageDescription added it is possible only when permission to Contacts granted.
    (it this an ios bug? ¯_(ツ)_/¯)

  3. Android - on all androids (prior 5.0 and aft) it is sufficient to grant only WRITE_CALENDAR permission to create events - except for any SONY phone (we have in our testing team).
    Sony phones requires READ_CALENDAR permission both with old 4.x and new (5..7) Android on board.
    App doesn't crashes, not it receives any exception - but without READ permission event in calendar is not creating.
    The need of such permission (READ) shows on old androids a weird message before installation about "this app can read and delete all your private calendars on this device".


Proposals: do not pop alerts from library (ios), exceptions are sufficient enough. This is because of need to show localized alert to user from app. I can send PR for this.

library does not link to ios

C:\Project> react-native link react-native-add-calendar-event
Scanning folders for symlinks in C:\Project\node_modules (34ms)
rnpm-install info Linking react-native-add-calendar-event android dependency
rnpm-install info Android module react-native-add-calendar-event has been successfully linked
rnpm-install info Linking react-native-add-calendar-event ios dependency
rnpm-install ERR! Something went wrong while linking. Error: Cannot read property 'match' of undefined
Please file an issue here: https://github.com/facebook/react-native/issues

Error building in Android: Could not find method google() for arguments [] on repository container

When I run-android it shows me this error:

A problem occurred evaluating project ':react-native-add-calendar-event'.
> Could not find method google() for arguments [] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-add-calendar-event": "^2.1.0",
ext {
    buildToolsVersion = "26.0.3"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}

I found workarounds for other packages and tried adding google() to build.gradle or exclude group: "com.android.support", module: 'support-v4' in the compile but with no success.

Question: will this ask to choose a calendar app if a user has multiple calendar apps?

Hello,

Some users would like to be able to choose their calendar app when adding an event. Currently, we use https://github.com/wmcmahan/react-native-calendar-events/, but this module adds events to the default calendar. I see that the Android implementation of this module is different (you're using Intent instead of ContentResolver), so I'm guessing this could be the case. Could you confirm? 😃

Thanks for your open-source work !

iOS and Android handle timezone differently

The following code yields the same (correct) event time on both iOS and Android:

const date = Platform.select({
  ios: moment(appointment.date),
  android: moment(appointment.date).utc()
})
const eventConfig = {
  title: `...`,
  startDate: date.format('YYYY-MM-DDTHH:mm:ss.SSS[Z]'),
  endDate: date.add(1, 'hour').format('YYYY-MM-DDTHH:mm:ss.SSS[Z]'),
};

Possibility to add an Alert ?

Hello there,
awesome library, love it ! I just have a question, is there a way to add an alert to the reminder ?
By default, there's none on iOS (see screenshot).

capture d ecran 2019-02-15 a 16 39 40

And so actually it seems that we cannot precise any alert on the eventConfig specs... Any ideas ?

Date is off by 4 hours in iOS dialogue

I am passing in a raw date from an ics file "20171010T160000" which has the format "YYYYMMDDTHHmmss". The correct local time (New York CIty) is 4pm.

Using moment.js I format it with

var date = moment(date, "YYYYMMDDTHHmmss").local().format('YYYY-MM-DDTHH:mm:ss.SSSZZ')

The output to console is correct "2017-10-10T16:00:00.000-0400", but when I pass it in to eventConfig as the "startDate" property, iOS displays the time as four hours ahead. It should be 4pm but displays as 8pm.

screenshot 2017-10-09 17 40 36

AAPT: No resource identifier found for attribute 'appComponentFactory' in package 'android'

/Users/iosdeveloper/Meet/XXXXXX/android/app/build/intermediates/manifests/full/release/AndroidManifest.xml:45:

AAPT: No resource identifier found for attribute 'appComponentFactory' in package 'android'

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processReleaseResources'.

Failed to process resources, see aapt output above for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1m 40s
162 actionable tasks: 148 executed, 14 up-to-date

so can you help us?
Thanks Advance

AddCalenderEvent.presentNewEventDialog fails with 'undefuned is not an object' on ios

This works fine on Android, but fails on iOs for me.
I created a podspec in the fork of this project and tried to use it to link instead of following the manual linking described in README.
https://github.com/shrutic/react-native-add-calendar-event/tree/master

Is there any restriction on why Podspec does not work for this project and we are restricted to use only the manual linking?


Update:
Seems like the library is indeed getting hit, but the iOS Native modules are not being recognized and causing the error. Below is the red screen I get when trying to launch on iOS device

error_calender

App crashes using AddCalendarEvent.presentEventDialog(eventConfig)

In my app, every time I try to call

AddCalendarEvent.presentEventDialog(eventConfig);

I got an app crash.

I tryed to wrap this call into a try/catch but probably the crash is at Java level and not at JS level.

    console.log ('trying to opening calendar');

    try {
      AddCalendarEvent.presentEventDialog(eventConfig)
        .then((eventInfo: { calendarItemIdentifier: string, eventIdentifier: string }) => {

          if (eventInfo) {
            console.warn(JSON.stringify(eventInfo));
          } else {
             console.warn('dismissed');
          }
        })
        .catch((error) => {
           handle error such as when user rejected permissions
           console.warn(error);
        }); 
    } catch (error) {
      console.log('here 4', error);
    }

How can I debug this issue?

Query: Is there a way we can add reminder?

Is there a way we can set alarm or reminder before xx amount of time before the startTime of the event? I can't find Alarm option in AddCalendarEvent.presentEventDialog(eventConfig).

Calendar UI is not opening on Android

Below is the source code I have used in my project, functionality works as expected while in debug mode on android but once it is released nothing happens.

Source Code


        var startDateNew = Moment.utc(getFormattedDate(`${this.props.start_date_timestamp}
        ${this.props.start_time.split(" ")[0]}`, "YYYY-MM-DDTHH:mm:ss.SSS[Z]"));
        const eventConfig = {
        title: this.props.title,
        startDate: startDateNew
        // and other options
        };


        Analytics.trackEvent("Start Date As per YYYY-MM-DDTHH:mm:ss.SSS[Z] " + startDateNew)

        AddCalendarEvent.presentEventCreatingDialog(eventConfig)
            .then((eventInfo: { calendarItemIdentifier: string, eventIdentifier: string }) => {
                Analytics.trackEvent("Calender Success" + JSON.stringify(eventInfo))
            })
            .catch((error: string) => {
                Analytics.trackEvent("Calender Error" + JSON.stringify(error))
            });

Error Logged
{"line":343,"column":12139,"sourceURL":"index.android.bundle"}

What could be the problem?

react-native 0.60

Is this package compatible with react-native 0.60, incl. new auto-linking feature?

Support for "All Day" events

Does this module support passing events into to the eventConfig with only dates and no times, or with the "All-day" option pre checked?

Warning on iOS in console

screen shot 2018-03-14 at 4 23 54 pm

I'm using RN 0.53.3

I believe it needs this inside of the implementation:

+ (BOOL)requiresMainQueueSetup {
  return YES;
}

undefined is not an object

I am really excited about this project but I can' get it to run.
I keep getting the following error:

simulator screen shot - iphone 6 - 2018-03-17 at 23 56 30

import { ScrollView, View } from 'react-native';
import React from 'react';
import { Input, Button } from 'react-native-elements';
import PropTypes from 'prop-types';
import SectionItem from '../contentScreens/SectionItem';
import Icon from 'react-native-vector-icons/MaterialIcons';
import * as AddCalendarEvent from 'react-native-add-calendar-event';

const eventConfig = {
title: ' hallo'
// and other options
};

  <Button
      title="Aktivität planen"
      // icon={{ name: 'code' }}

      onPress={() => {
        AddCalendarEvent.presentEventDialog(eventConfig);
      }}
    />

{
"main": "node_modules/expo/AppEntry.js",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"expo": "^25.0.0",
"moment": "^2.21.0",
"prop-types": "^15.6.1",
"react": "16.2.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",
"react-native-add-calendar-event": "^1.0.0",
"react-native-elements": "^0.19.0",
"react-native-parallax-scroll-view": "^0.20.1",
"react-native-shadow": "^1.2.2",
"react-native-vector-icons": "^4.5.0",
"react-native-video": "^2.0.0",
"react-navigation": "^1.2.1",
"react-redux": "^5.0.7",
"redux": "^3.7.2",
"redux-persist": "^4.10.2",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"ajv": "6.2.0",
"eslint": "4.18.1",
"eslint-config-prettier": "2.9.0",
"eslint-plugin-prettier": "2.6.0",
"prettier": "1.11.0"
}
}

Has anyone an Idea? Also when I put the whole content of the index file of the demo app into another app (as an component) I get the same error?!

Config "notes" is not working.

With your guide:
screen shot 2018-06-14 at 3 16 43 pm

But, when I used config "notes", it's not work. And I open your code, I saw you use config "description" (Android) to add description to my calendar. Please update document clearly.

Thanks.

Outlook calendar is not supported.

I have some Android users who are using Outlook calendar to manage their event. But it appears that when using react-native-add-calendar-event on my app, it wasn't suggesting them their Outlook app to save the event.
But no problem with some others applications on their phones (to save on Outlook calendar).

Does anyone know how I can manage that ? Can we do something ?

Thank's for the help !

Manual Android implementation - Fix README

Hey man, thanks for creating this library, awesome stuff!

Just a hint in your README file when implementing the package manually on Android, imports should be put in MainApplication.java not in MainActivity.java.

Just not make some newbies confused why it doesn't work :)

Cheers!

Build failed: com.android.ide.common.process.ProcessException: Failed to execute aapt

Hi, I'm encountering this error when trying to rebuild my project in Android but only after installing this library. I uninstalled the library, everything works, then reinstall and again get this error. I followed all of the instructions in the ReadMe but continue getting this error:

`:react-native-add-calendar-event:processReleaseResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-add-calendar-event:processReleaseResources'.

com.android.ide.common.process.ProcessException: Failed to execute aapt`

Any help would be greatly appreciated. I've scoured the web for solutions and found no hints or solutions.

Erro running the app

I download the zip file, run npm install and run app in Xcode and a error appear, like this:
#import <React/RCTUIManager.h>

React/RCTUIManager.h' file not found

How to include this file?

App crashes when disabling the only calendar app from settings

Thanks for the library.
Just want to raise the issue that when I "disable" the only calendar app (for eg.-google calendars) from the app settings, my app crashes and I get the crash detail as -

Exception in native call
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EDIT typ=vnd.android.cursor.item/event (has extras) }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1899)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1589)
at android.app.Activity.startActivityForResult(Activity.java:4229)
at com.facebook.react.bridge.ReactContext.startActivityForResult(ReactContext.java:355)
at com.vonovak.AddCalendarEventModule.presentEventAddingActivity(AddCalendarEventModule.java:108)
at com.vonovak.AddCalendarEventModule.presentEventDialog(AddCalendarEventModule.java:59)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:761)

Steps to reproduce -

  1. Open the app settings for google calendars.
  2. Tap on "Disable app" button
  3. Try to add the event on your app now.

Thanks.

Error occured while using compileSdkVersion 25

I am getting below error while compiling project with compileSdkVersion 25

public class AddCalendarEventModule extends ReactContextBaseJavaModule implements ActivityEventListener, LoaderManager.LoaderCallbacks {
       ^
J:\APP V2\node_modules\react-native-add-calendar-event\android\src\main\java\com\vonovak\AddCalendarEventModule.java:129: error:
method does not override or implement a method from a supertype
    @Override
    ^
J:\APP V2\node_modules\react-native-add-calendar-event\android\src\main\java\com\vonovak\AddCalendarEventModule.java:237: error:
method does not override or implement a method from a supertype
    @Override
    ^
Note: J:\APP V2\node_modules\react-native-add-calendar-event\android\src\main\java\com\vonovak\AddCalendarEventModule.java uses unchecked or unsafe operations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.