Please reference to Skygear Chat Quick Start guide for how to use the Skygear Chat Android SDK: https://docs.skygear.io/guides/chat/quick-start/android/
The Chat Plugin doc is at https://docs.skygear.io/android/plugins/chat/reference/. Check ChatContainer
for how things work.
To use the UIKit comes with Skygear Android, follow these steps:
That meant include these in build.gradle
of the project:
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven { url 'https://jitpack.io' }
}
}
And include these dependency in build.gradle
of the module:
dependencies {
// other dependencies
compile 'io.skygear:skygear:+'
compile 'io.skygear.plugins:chat:+'
compile 'io.skygear.plugins:chat_ui:+'
}
And configure Skygear Application Endpoint / API Key like these:
public class MyApplication extends SkygearApplication {
@Override
public String getSkygearEndpoint() {
return "change me with endpoint URL";
}
@Override
public String getApiKey() {
return "change me with API Key";
}
}
In your app manifest, include these lines for UIKit Activities:
<activity android:name="io.skygear.plugins.chat.ui.ConversationActivity" />
Currently Android UIKit only have the conversation view, you can use it after getting the conversation object from Chat API:
Intent i = new Intent(context, ConversationActivity.class);
i.putExtra(
ConversationActivity.ConversationIntentKey,
conversation.toJson().toString() // conversation object create from chat sdk
);
context.startActivity(i)
A bare minimal apps. assume you have done the configuration above, got SkygearApplication configured or configured manually with your application class, Here is an MainActivity as the launcher activity to start a Conversation View with a hard-coded user:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Container skygear = Container.defaultContainer(this);
skygear.getAuth().signupAnonymously(new AuthResponseHandler() {
@Override
public void onAuthSuccess(Record user) {
ChatContainer chatContainer = ChatContainer.getInstance(skygear);
chatContainer.createDirectConversation("7cd03660-f82f-4619-9fae-3b0c87fec7e9", "Chat Demo", null, new SaveCallback<Conversation>() {
@Override
public void onSucc(@Nullable Conversation conversation) {
Intent i = new Intent(getApplicationContext(), ConversationActivity.class);
i.putExtra(ConversationActivity.ConversationIntentKey, conversation.toJson().toString());
getApplicationContext().startActivity(i);
}
@Override
public void onFail(@Nullable String s) {
}
});
}
@Override
public void onAuthFail(Error error) {
}
});
}
}
If you believe you've found an issue with Skygear Android SDK, please feel free to report an issue.
Copyright (c) 2015-present, Oursky Ltd.
All rights reserved.
This source code is licensed under the Apache License version 2.0
found in the LICENSE file in the root directory of this source tree.
An additional grant of patent rights can be found in the PATENTS
file in the same directory.