Skip to content

Instantly share code, notes, and snippets.

@akalipetis
Last active October 13, 2015 12:38
Show Gist options
  • Save akalipetis/4197445 to your computer and use it in GitHub Desktop.
Save akalipetis/4197445 to your computer and use it in GitHub Desktop.
Code to be inserted for Warply SDK Integration
<!-- For Warply -->
<!-- Activity used for displaying Warply Campaigns. -->
<activity android:name="ly.warp.sdk.WarpViewActivity" />
<!-- Service used for handling Push Notifications. -->
<!-- If custom Push functionality is needed, replace this with your implementation. -->
<service android:name="ly.warp.sdk.WarpIntentService" />
<!-- Service used for updating user's location. -->
<service android:name="ly.warp.services.UpdateUserLocationService" />
<!-- Receiver used for receiving GCM Push Notifications. -->
<receiver
android:name="ly.warp.sdk.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="YOUR.PACKAGE.HERE" />
</intent-filter>
</receiver>
<!-- Receiver used for listening to location changes. -->
<receiver android:name="ly.warp.receivers.LocationChangedReceiver" />
<!-- Receiver used for listening to connectivity changes. -->
<receiver android:name="ly.warp.receivers.ConnectivityChangedReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<!-- Metadata containing your application's UUID, got from Warply backend. -->
<meta-data
android:name="warp_uuid"
android:value="YOUR_APP_UUID_HERE" />
<!-- Metadata declaring if Warply logs should be printed. If not present, default is true. -->
<!-- Consider swithing to false for publishing. -->
<meta-data
android:name="warp_debug_mode"
android:value="true" />
<!-- End for Warply -->
<!-- For Warply -->
<!-- Used to communicate with Warply servers -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Location is only accessed if set in the Warply backend -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Used by GCM Push Notifications -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="YOUR.PACKAGE.HERE.permission.C2D_MESSAGE" />
<!-- Used for better device profiling -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- Used for network statistics and switching off Warply when network is not available -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Declaring this permission makes sure no other application has access to your GCM Push Notifications -->
<permission
android:name="YOUR.PACKAGE.HERE.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<!-- End for Warply -->
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Initialize a new convertView, or get the recycled one
// Get references to the needed views: title, subtitle, hidden, date, image
Campaign c = mCampaigns.get(position);
title.setText(c.getTitle());
subtitle.setText(c.getSubtitle());
hidden.setText(c.getMessage());
java.text.DateFormat format = DateFormat.getMediumDateFormat(mContext);
date.setText(format.format(c.getExpires()));
ImageLoadingTask task = new ImageLoadingTask(image);
task.execute(c.getImageUrl());
return convertView;
}
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Campaign c = (Campaign) mAdapter.getItem(position); // Get clicked campaign here
Intent i = WarpViewActivity.createIntentFromSessionUUID(this, c.getSessionUUID());
startActivity(i);
}
Warply.getInbox(CallbackReceiver);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState
setContentView(R.layout.activity_main);
// Initialization code here
Warply.init(Context);
// Additional Warply code here
}
onFailure(int errorCode);
@Override
protected void onStart() {
super.onStart();
WarplySessionManager.onStartActivity(this);
}
@Override
protected void onStop() {
super.onStop();
WarplySessionManager.onStopActivity(this);
}
onSuccess(CampaignList list);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState
setContentView(R.layout.activity_main);
// Initialization code here
Warply.init(Context);
// This is the project ID, from the project you create at Google API Console
Warply.registerGCM("project_id");
// Additional Warply code here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment