This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MoviesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | |
public final int TYPE_MOVIE = 0; | |
public final int TYPE_LOAD = 1; | |
static Context context; | |
List<MovieModel> movies; | |
OnLoadMoreListener loadMoreListener; | |
boolean isLoading = false, isMoreDataAvailable = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Parameter Example | |
$data = array('post_id'=>'12345','post_title'=>'A Blog post'); | |
$target = 'single tocken id or topic name'; | |
or | |
$target = array('token1','token2','...'); // up to 1000 in one request | |
*/ | |
public function sendMessage($data,$target){ | |
//FCM api URL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FcmMessageService extends FirebaseMessagingService{ | |
@Override | |
public void onMessageReceived(RemoteMessage remoteMessage) { | |
//onMessageReceived will be called when ever you receive new message from server.. (app in background and foreground ) | |
Log.d("FCM", "From: " + remoteMessage.getFrom()); | |
if(remoteMessage.getNotification()!=null){ | |
Log.d("FCM", "Notification Message Body: " + remoteMessage.getNotification().getBody()); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FcmInstanceIdService extends FirebaseInstanceIdService { | |
@Override | |
public void onTokenRefresh() { | |
String token = FirebaseInstanceId.getInstance().getToken(); | |
Log.d("TOKEN",token); | |
sendFcmTokenToServer(token); | |
} | |
private void sendFcmTokenToServer(String token){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<service | |
android:name=".fcm.FcmMessageService"> | |
<intent-filter> | |
<action android:name="com.google.firebase.MESSAGING_EVENT"/> | |
</intent-filter> | |
</service> | |
<service | |
android:name=".fcm.FcmInstanceIdService"> | |
<intent-filter> | |
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Cloud Messaging / Notifications | |
compile 'com.google.firebase:firebase-messaging:9.0.2' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Analytics | |
com.google.firebase:firebase-core:9.0.2 | |
//Realtime Database | |
com.google.firebase:firebase-database:9.0.2 | |
//Storage | |
com.google.firebase:firebase-storage:9.0.2 | |
//Crash Reporting | |
com.google.firebase:firebase-crash:9.0.2 | |
//Authentication | |
com.google.firebase:firebase-auth:9.0.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add to the bottom of the file | |
apply plugin: 'com.google.gms.google-services' | |
//includes Firebase Analytics by default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
dependencies { | |
classpath 'com.google.gms:google-services:3.0.0' | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class MY_Controller extends CI_Controller { | |
public function __construct() | |
{ | |
parent::__construct(); | |
$this->load->library('session'); | |
//For example I have set logged_in = true in authentication on success | |
//Checking whether userdata logged_in not set ... if true redirecting to login screen | |
if(!$this->session->has_userdata('logged_in') || !$this->session->logged_in){ |