Giter Site home page Giter Site logo

eddyverbruggen / cordova-plugin-native-keyboard Goto Github PK

View Code? Open in Web Editor NEW
275.0 16.0 67.0 24.97 MB

:musical_keyboard: Add a Slack / WhatsApp - style chat keyboard to your Cordova app!

Java 2.40% Objective-C 97.60%
cordova phonegap keyboard messenger whatsapp slack chat

cordova-plugin-native-keyboard's Introduction

Native Keyboard

Every mobile app attempts to expand until it includes chat. Those applications which do not are replaced by ones which can.

-- Luke Wroblewski

   

Videos of iOS and Android running the included demo app.

So it's just a fancy keyboard?

You're damn right it is! 👍😊

A cross platform WhatsApp / Messenger / Slack -style keyboard even. For your Cordova app.

OK, let me try this..

Open a command prompt and do:

$ cordova create nativekeyboardtest
$ cd nativekeyboardtest
$ cordova plugin add cordova-plugin-native-keyboard

.. and for a nicer demo experience you'll also want to add these plugins:

$ cordova plugin add cordova-plugin-console
$ cordova plugin add cordova-plugin-actionsheet

.. now copy the contents of our demo over www/index.html, and do one of these:

$ cordova run ios
$ cordova run android

I'm no dummy, gimme details man!

ok ok - OK! The plugin is currently entirely focused on the messenger component, but this will extend into other areas in the future. With that being said, this is the current awesome API:

showMessenger

The bare minimum you need to show the messenger and do something useful with the text a user typed is this (make sure you wait for deviceready to fire):

NativeKeyboard.showMessenger({
  onSubmit: function(text) {
    console.log("The user typed: " + text);
  }
});

There are however many options you can pass in to tweak the appearance and behavior:

option default iOS Android description
onSubmit yes yes A function invoked when the user submits his input. Receives the text as a single property. Make sure your page is UTF-8 encoded so Chinese and Emoji are rendered OK.
onKeyboardWillShow yes no A function invoked when the keyboard is about to pop up. Receives the height as a single property.
onKeyboardDidShow yes yes A function invoked when the keyboard popped up. Receives the height as a single property.
onKeyboardWillHide yes no A function invoked when the keyboard is about to close.
onKeyboardDidHide yes yes A function invoked when the keyboard closed.
onMessengerBarHeightChanged yes yes A function invoked when the height of the messenger bar (without the keyboard) changes.
onTextChanged yes yes A function invoked when any key is pressed, sends the entire text as response.
autoscrollElement yes yes Highly recommended to pass in if you want to replicate the behavior of the video's above (scroll down when the keyboard opens). Pass in the scrollable DOM element containing the messages, so something like document.getElementById("messageList").
scrollToBottomAfterMessengerShows yes yes If autoscrollElement was set you can also make the list scroll down initially, when the messenger bar (without the keyboard popping up) is shown.
keepOpenAfterSubmit false yes yes Setting this to true is like the video's above: the keyboard doesn't close upon submit.
animated false yes yes Makes the messenger bar slide in from the bottom.
showKeyboard false yes yes Open the keyboard when showing the messenger.
text yes yes The default text set in the messenger input bar.
textColor #444444 yes yes The color of the typed text.
placeholder yes yes Like a regular HTML input placeholder.
placeholderColor #CCCCCC yes yes The color of the placeholder text.
suppressSuggestions true no yes Set this to false to allow predictive text on Android
backgroundColor #F6F6F6 yes yes The background color of the messenger bar.
textViewBackgroundColor #F6F6F6 yes yes The background color of the textview. Looks nicest on Android if it's the same color as the backgroundColor property.
textViewBorderColor #666666 yes no The border color of the textview.
maxChars yes limited Setting this > 0 will make a counter show up on iOS (and ignore superfluous input on Android, for now)
counterStyle "none" yes no Options are: "none", "split", "countdown", "countdownreversed". Note that if maxChars is set, "none" will still show a counter.
type "default" yes no Options are: "default", "decimalpad", "phonepad", "numberpad", "namephonepad", "number", "email", "twitter", "url", "alphabet", "search", "ascii"
appearance "default" yes no Options are: "light", "dark".
secure false yes no disables things like the Emoji keyboard and the Predicive text entry bar
leftButton yes yes See below
rightButton yes yes See below

leftButton

The button on the left is optional and can be used to for instance make a picture, grab a picture from the camera role, shoot a video, .. whatever you fancy, really as the implementation is entirely up to you.

As shown in the video's it's common to present these options as an ActionSheet, either native or a HTML widget.

option default iOS Android description
type yes limited Either "text" (Android only currently), "fontawesome" or "ionicon".
value yes yes Depends on the type. Examples: for "text" use "Send", for "fontawesome" use "fa-battery-quarter", for "ionicon" use "\uf48a" (go to http://ionicons.com, right-click and inspect the icon and use the value you find in :before). Note that some fonticons are not supported as the embedded fonts in the plugin may lag behind a little. So try one of the older icons first.
textStyle "normal" yes yes If type is "text" you can set this to either "normal", "bold" or "italic".
disabledWhenTextEntered false yes yes Set to true to disable the button once text has been entered.
onPress yes yes A function invoked when the button is pressed. Use this button to prompt the user what he wants to do next by for instance rendering an ActionSheet.

rightButton

The button on the right is used to submit the entered text. You don't need to configure this at all if you're happy with the default "Send" label as the entered text itself will be emitted through the onSubmit callback.

option default iOS Android description
type "text" yes yes Either "text", "fontawesome" or "ionicon".
value "Send" yes yes See the description of leftButton.value.
textStyle "normal" yes yes See the description of leftButton.textStyle.
onPress yes yes A function invoked when the button is pressed. Use this to for instance hide the messenger entirely after text was entered by calling NativeKeyboard.hideMessenger().

hideMessenger

It's likely your app only has 1 one page where you want to show the messenger, so you want to hide it when the user navigates away. You can choose to do this either animated (a quick slide down animation) or not.

NativeKeyboard.hideMessenger({
  animated: true // default false
});

showMessengerKeyboard

What if you have previously have shown the messenger and the user dismissed its keyboard, but you want to programmatically pop up the keyboard again? Use this:

NativeKeyboard.showMessengerKeyboard(
    // these functions are optional
    function() { console.log('ok') },
    function(err) { console.log(err)}
);

hideMessengerKeyboard

And if you want to programmatically hide the keyboard (but not the messenger bar), use this:

NativeKeyboard.hideMessengerKeyboard(
    // these functions are optional
    function() { console.log('ok') },
    function(err) { console.log(err)}
);

updateMessenger

Manipulate the messenger while it's open. For instance if you want to update the text programmatically based on what the user typed (by responding to onTextChanged events).

option type iOS Android description
text string yes yes Replace the messenger's text by this. The current text remains if omitted.
caretIndex number yes yes Position the cursor anywhere in the text range. Defaults to the end of the text.
showKeyboard boolean yes yes If false or omitted no changes to the keyboard state are made.
NativeKeyboard.updateMessenger(
    {
      text: "Text updated! ", // added a space so the user can continue typing
      caretIndex: 5,
      showKeyboard: true
    },
    function() { console.log('updated ok') },
    function(err) { console.log(err)}
);

Notes for iOS

Notes for Android

  • If you're using cordova-android 7.1 or higher, update the plugin to at least 2.0.0 because cordova-android 7.1 has slightly different internals, making installation fail. With older Cordova Android versions you may need to stick to the 1.x version though.
  • Make sure your activity in AndroidManifest.xml has the (default) android:windowSoftInputMode="adjustResize" (or adjustPan) property. Otherwise the inputfield will be hidden when the keyboard pops up.

I like it, hook me up!

This plugin has been a BEAST to implement and its maintenance is killing me already so I need to make this a commercial offering (with a free trial, see below) to keep it afloat. If you have a compelling reason to not pay for an unlocked version let me know and we'll work something out.

  • Look up the ID of the app you want to use the plugin with - you can find it at the top of config.xml and is something like io.cordova.hellocordova (if you have a different staging ID, or iOS and Android ID's are different just send me all of those and you'll get multiple license codes and pay for only one).
  • Send a one-time fee of USD 199 (or EUR 180) to my PayPal account and make sure to include your app ID. Want to use a bankaccount instead? No problem, just contact me at [email protected] for details.
  • You'll quickly receive a license key (and instructions) which you can use to install the plugin.
  • You can now forever use this version and any future version of this plugin for this app without restrictions.

Once the license key (abc in this example) is received, you can add the plugin like this:

cordova plugin add cordova-plugin-native-keyboard --variable LICENSE=abc

Or if your iOS and Android package ids are different, use this (supported since plugin version 1.5.8):

cordova plugin add cordova-plugin-native-keyboard --variable LIC_ANDROID=abc --variable LIC_IOS=xyz

I heard about a trial!?

ALL features are available without a license, but you'll be restricted to 5 minutes of usage. Just indefinitely kill and relaunch the app if you need more time ;)

Can you remove the license check for my prototype apps?

Sure, just add the word 'prototype' (case insensitive) anywhere in your packageid. Example: 'com.mycompany.myclientapp-PROTOTYPE' or 'com.mycompany.prototypes.myclientapp'.

cordova-plugin-native-keyboard's People

Contributors

diegovallarta avatar eddyverbruggen 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-native-keyboard's Issues

the "rightButton" behavior

hi @EddyVerbruggen
awesome new plugin

Android 6.0.1

[default behavior]
when I call "showMessenger" and use these option
var options = { text: "", placeholder: 'some word...', };
the keyboard show up
at the moment,the "rightButton" will not show up until I type some words in the message column (>0 word)

[suggestion behavior]
when I call "showMessenger" and use these option
var options = { text: "there have some default words", placeholder: 'some word...', };
the keyboard show up
at the moment,the message column have some default words already,but it still must type some words and the "rightButton" will show up,I suggest if the text have some default words already,just Direct display the "rightButton"

native keyboard features

hai, it is really very useful. Thanks for this plugin.

We have some doubt please help me
In demo/index_all_features.html file we are added the configureNativeKeyboard how we add the "keepOpenAfterSubmit" and will / did keyboard show / hide function. i try to add but it is not working please advice.......

Question: still maintained ?

I am planning to use this plugin in my app and I am wondering if it is still maintained? If yes I would buy it else I wouldn't.

Feature request to initialize the text input field to any string of characters.

Is it possible to initialize the text input field with text (any number of characters) that I specify? If the user types in text and then closes the keyboard without pressing the Send button, I need to restore that text when the user opens the keyboard again in certain cases. I need to make the decision as to what text gets initialized. The text that was last entered should not always be restored the next time the keyboard is opened.

Thanks

JS Unexpected plugin result: {"contentHeight":31,"contentHeightDiff":0}

Hi Eddy,

I thought I should report this error/warning message which I've been getting ever since I started using the plugin. It never caused any issues that I am aware of so I never reported it. I thought I should report it now just in case it is related to another issue.

I get the following error from NativeKeyboard.js when I tap on the input text bar to open the keyboard:

JS Unexpected plugin result: {"contentHeight":31,"contentHeightDiff":0}

I also get the same exact error when I close the keyboard using the Android back button. I have definitely seen the error in both Android and iOS, but right now it only seems to be happening in Android.

Thanks

iOS doesn't honor overlaywebview = false

The message toolbar is shifted down by 20px
In previous version the message toolbar was positioned ok, but the content of the webview was shifted up by 20px under the status bar

Send Image and Text

My question is if with this plugin I can send multimedia with text, in the same message. Similar to Whatsapp, that when I choose the image or video can write a message.

And if it's impossible any idea or plugin that how implement with cordova

Thanks

Keyboard show/hide events fire when the orientation changes

Hi Eddy,

The following events fire when the input bar and keyboard are visible and the device orientation changes to landscape or portrait:

onKeyboardWillHide, onKeyboardDidHide, onKeyboardWillShow and onKeyboardDidShow

The keyboard remains visible when the orientation is changed. These events do not fire when you change the orientation while the input bar is visible and the keyboard is hidden. Was this intentional?

Android 4.4 -- The Messenger text box does not show up.

The input box is not being shown on Android 4.4. The same code works perfectly on IOS.
I get the below message in the console:

Error in showMessenger: Already showing 

And it also crashes on android. Here is the log:

D/STATUSBAR-IconMerger( 1031): checkOverflow(240), More:false, Req:false Child:3
D/AndroidRuntime(24451): Shutting down VM
W/dalvikvm(24451): threadid=1: thread exiting with uncaught exception (group=0x41803da0)
E/AndroidRuntime(24451): FATAL EXCEPTION: main
E/AndroidRuntime(24451): Process: com.app.android, PID: 24451
E/AndroidRuntime(24451): java.lang.NullPointerException
E/AndroidRuntime(24451): 	at nl.xservices.plugins.nativekeyboard.lib.NativeKeyboardImpl.cleanup(NativeKeyboardImpl.java:432)
E/AndroidRuntime(24451): 	at nl.xservices.plugins.nativekeyboard.lib.NativeKeyboardImpl.access$1400(NativeKeyboardImpl.java:47)
E/AndroidRuntime(24451): 	at nl.xservices.plugins.nativekeyboard.lib.NativeKeyboardImpl$8$1.onAnimationEnd(NativeKeyboardImpl.java:411)
E/AndroidRuntime(24451): 	at android.view.animation.Animation$3.run(Animation.java:374)
E/AndroidRuntime(24451): 	at android.os.Handler.handleCallback(Handler.java:733)
E/AndroidRuntime(24451): 	at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(24451): 	at android.os.Looper.loop(Looper.java:146)
E/AndroidRuntime(24451): 	at android.app.ActivityThread.main(ActivityThread.java:5653)
E/AndroidRuntime(24451): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(24451): 	at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(24451): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
E/AndroidRuntime(24451): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
E/AndroidRuntime(24451): 	at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(  831):   Force finishing activity com.app.android/.MainActivity
D/SensorManager( 1201): unregisterListener ::   
I/dumpstate(24738): begin
I/SpenGestureManager(  831): setFocusWindow0
D/PointerIcon(  831): setMouseIconStyle1 pointerType: 1001iconType:101 flag:0
D/PointerIcon(  831): setMouseCustomIcon IconType is same.101
D/STATUSBAR-StatusBarManagerService(  831): manageDisableList what=0x0 pkg=WindowManager.LayoutParams
D/CrashAnrDetector(  831): processName: com.app.android
D/CrashAnrDetector(  831): broadcastEvent : com.app.android data_app_crash
I/ThermalCoreControl(  831): ******* gpu temp[0] : 41	
I/ThermalCoreControl(  831): ******* gpu temp[1] : 46	
I/ThermalCoreControl(  831): 
I/ThermalCoreControl(  831): >>> ++++***
W/ContextImpl(  831): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1515 com.android.server.analytics.data.collection.application.CrashAnrDetector.broadcastEvent:296 com.android.server.analytics.data.collection.application.CrashAnrDetector.processDropBoxEntry:254 com.android.server.analytics.data.collection.application.CrashAnrDetector.access$100:60 com.android.server.analytics.data.collection.application.CrashAnrDetector$1.onReceive:102 
I/SurfaceFlinger(  229): id=198 createSurf (1x1),1 flag=4, jos
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/ThermalMonitor(  831): Foreground Application Changed: com.google.android.googlequicksearchbox
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
E/android.os.Debug(  831): !@Dumpstate > sdumpstate -k -t -z -d -o /data/log/dumpstate_app_error
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
E/SMD     (  223): DCD ON
W/ActivityManager(  831): mDVFSHelper.acquire()
V/WindowManager(  831): rotationForOrientationLw(orient=5, last=0); user=0 USER_ROTATION_LOCKED sensorRotation=-1 mLidState=-1 mDockMode=0 mHdmiPlugged=false mAccelerometerDefault=false gripRotationLock=false
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/PhoneStatusBar( 1031): setSemiTransparentMode=false, mTransparentMode=false, mSemiTransparentMode=false, mMultiWindowMode=false
D/PhoneStatusBar( 1031): checkBarMode(0)
D/StatusBarManagerService(  831): semi p:1233,o:f
I/SurfaceFlinger(  229): id=199 createSurf (720x1280),1 flag=4, HEL
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/PhoneStatusBar( 1031): checkBarMode(2)
D/STATUSBAR-StatusBarManagerService(  831): manageDisableList what=0x0 pkg=WindowManager.LayoutParams
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
E/wpa_supplicant( 1021): IAPP SNAP_HDR Mismatch
W/ActivityManager(  831): mDVFSHelper.release()
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/KeyguardUpdateMonitor( 1031): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 1031): handleKeyguardVisibilityChanged(1)
D/SSRMv2:SIOP(  831): SIOP:: AP = 380, Delta = 10
I/ThermalCoreControl(  831): ******* gpu temp[0] : 41	
I/ThermalCoreControl(  831): ******* gpu temp[1] : 45	
I/ThermalCoreControl(  831): 
I/ThermalCoreControl(  831): >>> ++++***

IOS: https://s12.postimg.org/xcz6jlail/Screen_Shot_2016_11_27_at_1_22_46_PM.png
Android: https://s22.postimg.org/4kzn0dtfl/Screenshot_2016_11_27_13_20_31.png

ionic 3 with keyboard plugin

Hi,
This is what I get when I add it to a project with the latest Ionic bits.

I copied over the demo code to my project. See video:

https://microsoft-my.sharepoint.com/personal/v-jormc_microsoft_com1/_layouts/15/guestaccess.aspx?guestaccesstoken=Q%2bf%2fwoKhvCfeWuA6uWETE866b%2f3AQ3iFtQ%2fMVpmfY84%3d&docid=2_1c825bbd9340d4c2faf475752f8bf9b49&rev=1

TypeScript file looks like this:

import { Component, OnInit, ElementRef } from '@angular/core';
import { Observable } from 'rxjs';
import { User } from '../../models/user.model';
import { UsersService } from '../../services/users.service';
import { Thread } from '../../models/thread.model';
import { ThreadsService } from '../../services/threads.service';
import { Message } from '../../models/message.model';
import { MessagesService } from '../../services/messages.service';
//import { Keyboard } from '@ionic-native/keyboard';
import { NativeKeyboard, NativeKeyboardOptions } from '@ionic-native/native-keyboard';

@Component({
  selector: 'chat-window',
  templateUrl: './chat-window.component.html',
  providers: [NativeKeyboard]
})
export class ChatWindowComponent implements OnInit {
  messages: Observable<any>;
  currentThread: Thread;
  draftMessage: Message;
  currentUser: User;
  //nativeKeyboardOptions: NativeKeyboardOptions

  constructor(public messagesService: MessagesService,
    public threadsService: ThreadsService,
    public UsersService: UsersService,
    public el: ElementRef,
    private nativeKeyboard: NativeKeyboard) {
  }

  ngOnInit() {

    let options = {
      onSubmit: (text:any) =>
      {
        console.log('this.sendMessage(text); ' + text);
        this.sendMessage(text);
      },
      onKeyboardWillShow: function (height) {
        console.log("keyboard will show, height is: " + height);
        //appendMessage("keyboard will show, height is: " + height);
      },
      onKeyboardDidShow: function (height) {
        console.log("keyboard shows, height is: " + height);
        //appendMessage("keyboard shows, height is: " + height);
      },
      onKeyboardWillHide: function () {
        console.log("keyboard will hide");
      },
      onKeyboardDidHide: function () {
        console.log("keyboard did hide");
      },
      onTextChanged: function(newText) {
        console.log("text changed to: " + newText);
        //appendMessage(newText);
      },
      showKeyboard: true,
      type: "twitter", // iOS only, default (default) | decimalpad | phonepad | numberpad | namephonepad | number | email | twitter | url | alphabet | search | ascii
      appearance: "light", // iOS only,  light (default) | dark
      secure: false, // iOS only,  default false, disables things like Emoji and Predicive text entry
      autocorrectionEnabled: false, // on iOS this hides the 'predictive text' bar
      scrollToBottomAfterMessengerShows: true,
      autoscrollElement: document.getElementById("messages"), // default unset
      keepOpenAfterSubmit: true, // default false
      animated: true,
      text: "This has been prefilled",
      placeholder: 'Type your message..',
      placeholderColor: "#DDDDDD",
      textViewBackgroundColor: "#F6F6F6",
      backgroundColor: "#F6F6F6",
      textViewBorderColor: "#777777", // iOS only
      maxChars: 140, // setting this > 0 will make the counter show up on iOS (and ignore input on Android, for now)
      counterStyle: 'countdownreversed', // iOS only currently, note that 'none' still shows a counter in case maxChars is set
      textColor: '#555555',
      // this button is best suited for picking media (camera / cameraroll / last image) from an actionsheet
      leftButton: {
        type: 'ionicon', // or 'text' (Android only currently) or 'fontawesome'
        value: '\uf48a', // http://ionicons.com/ - right-click and inspect the :before value (don't forget the \uf !)
        //color: '#ff0000', // default blue on iOS, grey on Android
        textStyle: 'normal', // if type is 'text', you can set this to 'normal' (default), 'bold', 'italic'
        disabledWhenTextEntered: false, // default false
        onPress: function () {
          // if (window.plugins && window.plugins.actionsheet) {
          //   window.plugins.actionsheet.show({
          //     androidTheme: window.plugins.actionsheet.ANDROID_THEMES.THEME_DEVICE_DEFAULT_LIGHT,
          //     buttonLabels: ['Take Photo or Video', 'Use Last Photo Taken', 'Choose From Library'],
          //     addCancelButtonWithLabel: 'Cancel'
          //   }, function(index) {
          //     if (index != 4) { // which is 'cancel'
          //       console.log("Picked index " + index + ".. you'll need to implement the rest yourself ;)");
          //     }
          //   });
          // } else {
          //   alert("Left button pressed - if you install cordova-plugin-actionsheet you'll see a nice ActionSheet in this demo.");
          // }
        }
      },
      rightButton: {
        type: 'text', // or 'fontawesome' or 'ionicon', default 'text'
        value: 'Send', // 'fa-battery-quarter', // '\uf2c3', // 'Send', // default 'Send'
        textStyle: 'bold', // 'normal' (default), 'bold', 'italic'
        //color: '#FF0000', // default iOS blue
        onPress: function () {
          console.log("Right button was pressed - text was passed to 'onSubmit' if provided.");
        }
      }
    };
    var onSuccess = function () {
      console.log("Show Messenger succeeded!");
    };
    var onError = function (message) {
      console.log("Got error message: " + message);
    };


    this.nativeKeyboard.showMessenger(options);

Interested in purchasing this if it works well in a POC.

Thanks

Changing the color of the outline around the input

My app is themed very dark, with black everywhere: Screenshot

The one color I can't customize with the currently available options is the outline around the native text input (as seen in the screenshot, it's still set to a light grey).

Can an option be added to allow this outline color to be changed?

Thanks for the fantastic library, by the way. I've purchased a license and will probably purchase more for future apps I create.

WKWebView

Hi Eddy,

I'm trying to use your plugin for a my personal project.
To improve the performances I've switched from UIWebView to WKWebView.

In this operation I've seen that while I'm using your plugin (even just using the function showMessenger) and try to use another plugin by the keyboard's left button (or with a custom button in the view), the view seems "freezed".
In fact, if I try to tap the screen, trying to click again the same button clicked one moment ago, the app seems blocked.

but if I try to put the app in background and immediately in foreground, the view it's updated, and I can saw what I've done.
I've try different plugins and the bug happen with all of them.

Can you help me please?

Best Regards

BETA test

Hi folks,

(Pinging @enricodeleo, @pbudner, @crissi, @AlexDisler, @jcesarmobile because you fine folks starred the repo previously)

If you are interested in BETA testing this plugin, please download it, unzip it and install it from a local folder: cordova plugin add ../../path-to-unzipped-plugin

Then take a look at demo/index.html to see what's possible.

This plugin will give you full access to the native keyboard properties like keyboard color, keyboard type, the accessory bar, etc. As a bonus I've added an iMessage/WhatsApp/Slack - style messenger component which you can play with.

This is all available for iOS, I may add the messenger component for Android later. Not sure yet. I'm also not sure yet if there will be a FREE/PRO version of this plugin, but during the BETA it's all available of course.

If you have any feedback about the features or find issues please just dump 'em in this issue as a comment.

Thanks in advance,
Eddy

placeholder property does not work in iOS

The placeholder property does not work in iOS (10.x). It works fine in Android.

Nothing appears in the text input field when you add the following property:

placeholder: 'Type your message..'

Incorrect keyboard height when the keyboard is visible and the device orientation changes

Hi Eddy,

I am currently testing the cordova native keyboard plugin using an iPhone 5s (iOS 10.2.1) and an HTC One Mini (Android 4.2.2).

I am trying to figure out how to get the correct keyboard height when the keyboard is visible in portrait orientation and the device is changed to landscape orientation.

When the keyboard is visible and the orientation of the device is changed from portrait to landscape, the onKeyboardWillShow and onKeyboardDidShow callbacks are both called and each receives the current keyboard height. I need an accurate keyboard height so I can change the height of a scrollable list which appears above the keyboard. The list expands or contracts when the keyboard becomes visible or hidden.

The first time the orientation is changed from portrait to landscape, the onKeyboardWillShow and onKeyboardDidShow callbacks are called, but they both return the old portrait keyboard height instead of the new landscape keyboard height. The height I need in order to resize the list is the new landscape keyboard height.

When the orientation is changed back to portrait, both the onKeyboardWillShow and onKeyboardDidShow callbacks are called, but they return the landscape keyboard height instead of the new portrait keyboard height.

I am able to get the portrait keyboard height if the app is initially opened in portrait orientation, but I cannot get the correct landscape keyboard height when I need it. Is there any way to get the landscape keyboard height when the keyboard is visible and the device is initially changed to device orientation?

Thanks

Feature Request to add an onKeyboardWillHide callback function

I am using the onKeyboardDidHide function to trigger the resizing of a list which appears on the same page as the native keyboard control. My app appears somewhat “choppy” because too much time elapses between the time the keyboard is minimized and the time the onKeyboardDidHide function is invoked. It would appear much smoother if there was an onKeyboardWillHide function that is invoked prior to the keyboard minimizing so I can start resizing the list sooner.

BTW - The cordova-plugin-keyboard plugin has both an onKeyboardWillHide and an onKeyboardWillShow callback.

Thanks

Not working with WKWebView

Hi!
The plugin causes the webview crash when any other plugin is used.
Wrote email, tried to call.
Any advise on where to look to fix this?

iOS UI Glitch

I've been experiencing issues on ionic2 on iOS (Works great on Android).

When trying to hide the keyboard during a view change. The next view doesn't properly render in the space where the keyboard used to be (White bar at the bottom) and all the actual links are no longer inline with their UI elements (See screenshot). So to click on an element you need to click just below or just above it.

I've tried playing around with running the hide keyboard in different life cycle hooks (ionViewWillLeave, ionViewDidLeave etc...) and the behaviour gets slightly better or worse but nothing solves the issue.

Great plugin though! Already worlds better than anything we have tried!

img_7690

Programmatically pop up the keyboard

After you've shown the messenger (and optionally automatically popped up the keyboard), the user may dismiss the keyboard (but the messenger bar will remain on screen unless you've called hideMessenger).

You may now want to programmatically pop up the keyboard again, so I've just added showMessengerKeyboard to version 1.2.0 of this plugin.

Feature Request: Emoji Keyboard for left button.

Is it possible to bring up emojis after clicking the left button? Any options to the left button that might open up the emoji keyboard?
In plain html this brings up emoji keyboard

<input type="textShortMessage" />

Incompatible with cordova-plugin-admob-free

When I want to monetize my App with AdMob and use this Plugin, only the Banner-Ad from AdMob will be shown after calling NativeKeyboard.showMessenger.

bildschirmfoto_2017-05-04_10-20-39

It is reproducable with all free AdMob Plugins for Cordova.
Looks like NativeKeyboard shrinks the WebView of my App to 0px.

Additional:
The AdMob Plugin creates new WebViews to display the Ads.

Feature Request to add an onKeyboardWillShow callback function

I would like to request that you add an onKeyboardWillShow function to compliment the onKeyboardWillHide function. It will allow me to resize my list sooner thereby increasing the response time of my app.

After implementing the new onKeyboardWillHide callback function and getting much better results when resizing my list at the time the keyboard is closed, it has now become apparent that there is too much lag time after opening the keyboard and waiting for the onKeyboardDidShow function to be called before resizing my list.

Thank you

WKWebView iOS Header UI Glitch

Hey @EddyVerbruggen I wanted to say thanks to the awesome plugin you wrote!

It works great with WKWebView on my app. The only thing I noticed since I started to use WKWebView is that when I open the native-keyboard and close it (by clicking the view) the header is pulled up by the space the inputfield down under needs. To demonstrate you that I added two buttons in the View

Arrow-Down-Button to hide the native-keyboard only using

hideNativeKeyboard(){
    let options:NativeKeyboardOptions= <NativeKeyboardOptions>{};
    options.animated = false;
    this.nativeKeyboard.hideMessenger(options);
  }

Arrow-Up-Button to show the keyboard again using

let options:NativeKeyboardOptions = {
        onSubmit: this.sendMessage,
        showKeyboard: false,
        type: "twitter",
        appearance: "light",
        secure: false,
        scrollToBottomAfterMessengerShows: true,
        autoscrollElement: this.content.getScrollElement(),
        keepOpenAfterSubmit: true,
        animated: true,
        text: "",
        placeholder: 'Schreib eine Nachricht',
        placeholderColor: "#DDDDDD",
        textViewBackgroundColor: "#FFFFFF",
        backgroundColor: "#F6F6F6",
        textViewBorderColor: "#F6F6F6",
        maxChars: 0,
        counterStyle: 'none',
        textColor: '#555555',
        leftButton: {
          ...
        },
        rightButton: {
          ...
        }
      };
      this.nativeKeyboard.showMessenger(options);

In action, it looks like this:

ezgif com-video-to-gif

In the video you see that when I open up the keyboard to type something and it than closes, the header is cutted. And when I hide the keyboard, the header is totally normal again. this is only happening since I installed the Cordova-Plugin-WKWebView-Engine from the Ionic-Team
I don't really know what is going wrong here but for me it seems like the native input-field is pushing up the whole "screen" or Webview.

Any suggestions?

ionic 2 autoscrollElement

Hi,
I 'm building message page with ionic 2. Unfortunately if keyboard pops up scrolling content will not scrolled to the last message.
I tried something like this

<ion-content id="content">
  <div id="messages" class="messages">
    <div [class]="'message message-'+ message.ownership" *ngFor="let message of messages">
      <div class="message-content">
        {{message.content}}
      </div>
    </div>
  </div>
</ion-content>

autoscrollElement: document.getElementById('messages');

Thanks

Incompatible with cordova-plugin-googlemaps on Android

When using this Plugin together with cordova-plugin-googlemaps the chatbox will be behind the webview on the z-axis.

As discribed here:
The googlemaps plugin works by displaying the map behind the app and just adding css to each layer in the webview to make its background transparent - so it seems that it places all then native components behind the webview taking the chatbox with it.

Is there some fix to be done here? or will this be a bug with cordova-plugin-googlemaps

This only happens on Android - IOS works fine

Wow! But some questions left!

Hey Eddy,

I really want to make love with you right now! What an awesome plugin. One of the biggest showstopper ever on Cordova. I hacked around so many days to get a "native like" feeling in my chatapp, and it's still buggy sometimes (timing problems) and annoying with the push-out webview and all sorts of css and js hacks to get "it back and scroll to that position without letting the keyboard overlay my chatmessages"

So I am really happy to see this. I will do a trial first, but tell me, do I have to buy that plugin for every single app? (because they have different app-ids). Or is this a one-time-fee for any app I will make?

iOS text selection dot clipped while touching screen

Steps to reproduce:

  • Enter text on iOS
  • Select a range of text
  • Touch screen in selected range, as if to move the blue start or end marker

Result:

  • The blue dots at the range start/end markers are clipped by the text box while the screen is touched

Expected result:

  • The blue dots are not clipped, just as when the screen is not touched

img_5618

IOS scrollbar ionic 2 glitch

Hi,
I'm using ionic 2 and unfortunately it is not working pretty well with this framework but this plugin is really great 👍 . Vertical scrollbar goes out of scrollable context. it does not matter if keyboard is hidden or open. It is visible on video here The issue remains also on real device.
Thanks for any help how to fix it
Michal

Ionic Project - Keyboard showing up after I hit the back button

Hey Eddy,

I added the keyboard plugin to my project today. You can see in this video that after I go to my chat page, then hit the back button, the keyboard input is showing up on the previous page somehow.

Thanks

P.S. There are some issues with the scrolling I referenced in the #28 post. I can work on a simple repo to see if we can get to the bottom of these issues!

Error in build after adding plugin

Here are the build error logs.
PS: I have no idea about objective-c or xcode.

2016-11-18 20:43:51.228 xcodebuild[31889:7318115] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 115. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.

2016-11-18 20:43:51.230 xcodebuild[31889:7318115] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 115. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.

2016-11-18 20:43:51.230 xcodebuild[31889:7318115] Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected character / at line 1" UserInfo={NSDebugDescription=Unexpected character / at line 1, kCFPropertyListOldStyleParsingError=Error Domain=NSCocoaErrorDomain Code=3840 "Missing ';' on line 115" UserInfo={NSDebugDescription=Missing ';' on line 115}}

Request for an additional row of user-defined buttons

Hi Eddy,
It would be very powerful if you offered an additional row of user-defined buttons (up to 5) that appeared in the input bar below the textbox. The input bar should only expand to accommodate the row of buttons if at least 1 button is defined. The buttons can be used for additional actions or to indicate attachments such as photos. They would not replace the current left and right buttons and would require the same type of functionality.

Thank you.

TypeScript support?

Hi,
Do you have an example of how I can invoke NativeKeyboard.showMessenger from TypeScript?
Essentially, can we import NativeKeyboard and use the functions in TypeScript?

I have an ionic3 app and only want the keyboard on one of my pages so I do not want to show the Keyboard on index.html like the demo does. Trying to figure how I can do this with ionic. Any ionic3 sample repos you know of?

Tryng to start basic with :
NativeKeyboard.showMessenger({
onSubmit: function(text) {
console.log("The user typed: " + text);
}

Thanks

Need the height of the text input bar when the keyboard is closed

Hi Eddy,

The text input bar is rendering a different height depending on what type of Android device it is running on. For example, the height might be 64 pixels on one device and 84 pixels on another. The text input bar is always the same height on every iOS device I have tested.

The only place the plugin returns a height is when the onKeyboardWillShow and onKeyboardDidShow events are called, but this height includes the height of the keyboard.

Can you return the height of the text input bar without the keyboard height in a new event that is fired when the showMessenger method is called? Or maybe add a new method which just returns the text input bar height? Does this make sense?

Thanks

Allow updating the messenger's text while it's open

Add this feature with all optional properties:

NativeKeyboard.updateMessenger(
    {
      text: "Text updated! ",
      caretIndex: 5,
      showKeyboard: true
    },
    function() { console.log('updated ok') },
    function(err) { console.log(err)}
);

Selecting "Format" from the iOS copy/paste context menu breaks context menu

Steps to reproduce

  • Enter text (iOS)
  • Long press on word
  • Pick "select" from the context menu to select word
  • The extended Cut/Copy/Paste/Replace.../Look Up/Share../Format context menu appears
  • Pick the "Format" option
  • Press the "Send" button

Result

Send (right button) does not perform any action any more, neither does the plus-button (left button).

Expected result

There probably shouldn't be a "Format" option in the menu to start with.

Can't override options of NativeKeyboard

I have an Ionic 3 application and I am trying to show the nativeKeyboard on a page (ChatPage).
At the first time I do this it works just fine but if i hide the messenger and setup the messenger again with different options, It doesn't override the older ones. I don't know if this is because I haven't paid it yet but It seems very strange to me and in the README it says that only the usage is restricted to 5 minutes, not that you can just show the messenger once.

setupMessenger(){

    this.platform.ready().then(()=>{

      let options = {
        onSubmit: this.sendMessage,
        onKeyboardDidHide:this.onKeyboardHide,
        onKeyboardDidShow:null,
        onKeyboardWillHide:this.onKeyboardHide,
        onTextChanged:null,
        onKeyboardWillShow: this.onKeyboardShow,
        showKeyboard: false,
        type: "twitter",
        appearance: "light",
        secure: false,
        //autocorrectionEnabled: true,
        scrollToBottomAfterMessengerShows: true,
        autoscrollElement: this.content.getScrollElement(),
        keepOpenAfterSubmit: true,
        animated: true,
        text: "",
        placeholder: 'Schreib eine Nachricht',
        placeholderColor: "#DDDDDD",
        textViewBackgroundColor: "#FFFFFF",
        backgroundColor: "#F6F6F6",
        textViewBorderColor: "#F6F6F6",
        maxChars: 0,
        counterStyle: 'none',
        textColor: '#555555',

        leftButton: {
          type: 'ionicon',
          value: '\uf474',
          textStyle: 'normal',
          disabledWhenTextEntered: false,
          onPress: function () {

          }
        },
        rightButton: {
          type: 'ionicon',
          value: '\uf474',
          textStyle: 'normal',
          onPress: function () {

          }
        }
      };
      NativeKeyboard.showMessenger(options);
    });
  }

And this is my hide Method:

hideNativeKeyboard(){
    let options = {
      animated: false
    };
    NativeKeyboard.hideMessenger(options);
  }

Both get called once:

ionViewWillEnter(){
    this.platform.ready().then(()=>{
      this.setupMessenger();
    });
  }

ionViewWillLeave(){
    this.hideNativeKeyboard();
  }

And when I do it like this It works on the first chat page. for every other page it does not work.
Any idea what's going on ?
Currently I am using the version "version": "1.4.1" of the nativeKeyboard

Environment information (if needed):

cli packages: (/Users/herberthart/Project/node_modules)

    @ionic/cli-plugin-cordova       : 1.6.1
    @ionic/cli-plugin-ionic-angular : 1.4.1
    @ionic/cli-utils                : 1.7.0
    ionic (Ionic CLI)               : 3.7.0

global packages:

    Cordova CLI : 7.0.1 

local packages:

    @ionic/app-scripts : 2.0.1
    Cordova Platforms  : ios 4.4.0
    Ionic Framework    : ionic-angular 3.5.3

System:

    Node       : v8.2.1
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b 
    ios-deploy : 1.9.1 
    npm        : 5.2.0 

Incompatible with Admob Plugin

I try it a second time. I open this issue some weeks ago, but the issue was closed without fixing the bug (#40).
The problem still exist on Android devices when creating the app with phonegap.

956a5d9e-30b3-11e7-888d-271795ea6aaf

If you initialize the admob ads and open the keyboard, the other part above the keyboard is black, only the Banner-Ad from AdMob will be shown after calling NativeKeyboard.showMessenger.
It is reproducable with all free AdMob Plugins for Cordova.
Looks like NativeKeyboard shrinks the WebView of my App to 0px.
Currently I have the cordova-plugin-admob-simple version 3.3.4 andcordova-plugin-native-keyboard version 1.3.2. But all of the newer version of native keyboard plugin don`t work either.

Additional:
The AdMob Plugin creates new WebViews to display the Ads.

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.