Как получить уведомление / напоминание для друзей Facebook о предстоящих днях рождения

Я пишу приложение, в котором я получаю список всех своих друзей на Facebook..

Но теперь я хочу добавить в свое приложение еще одну функцию, чтобы получать уведомления/напоминания о предстоящих днях рождения друзей.

Я использую код ниже, чтобы получить список всех друзей:

 public class FriendListAdapter extends BaseAdapter implements
        SectionIndexer {
    private LayoutInflater mInflater;

    private GetProfilePictures picturesGatherer = null;
    FriendsList friendsList;
    private String[] sections;

    Hashtable<Integer, FriendItem> listofshit = null;

    public FriendListAdapter(FriendsList friendsList) {

        this.friendsList = friendsList;
        sections = new String[getCount()];
        listofshit = new Hashtable<Integer, FriendItem>();


        for (int i = 0; i < getCount(); i++) {
            try {

                sections[i] = jsonArray.getJSONObject(i).getString("name")
                        .substring(0);
                sections[i] = jsonArray.getJSONObject(i)
                        .getString("birthday").substring(1);


            } catch (JSONException e) {
                sections[i] = "";

            }
        }
        if (picturesGatherer == null) {
            picturesGatherer = new GetProfilePictures();
        }
        picturesGatherer.setAdapterForListener(this);
        mInflater = LayoutInflater.from(friendsList.getBaseContext());
    }

    public int getCount() {

        if (jsonArray == null)
            return 0;
        return jsonArray.length();
    }

    public Object getItem(int position) {

        return listofshit.get(position);
    }

    public long getItemId(int position) {

        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {


        JSONObject jsonObject = null;
        try {
            jsonObject = jsonArray.getJSONObject(position);
        } catch (JSONException e) {

        }

        FriendItem friendItem;

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.single_friend, null);
            friendItem = new FriendItem();

            convertView.setTag(friendItem);
        } else {
            friendItem = (FriendItem) convertView.getTag();
        }

        friendItem.friendPicture = (ImageView) convertView
                .findViewById(R.id.picture_square);
        friendItem.friendName = (TextView) convertView
                .findViewById(R.id.name);
        friendItem.friendDob = (TextView) convertView
                .findViewById(R.id.dob);
        friendItem.friendLayout = (RelativeLayout) convertView
                .findViewById(R.id.friend_item);

        try {
            String uid = jsonObject.getString("uid");
            String url = jsonObject.getString("pic_square");
            friendItem.friendPicture.setImageBitmap(picturesGatherer
                    .getPicture(uid, url));
        } catch (JSONException e) {

            friendItem.friendName.setText("");
            friendItem.friendDob.setText("");
        }

        try {
            friendItem.friendName.setText(jsonObject.getString("name"));
            friendItem.friendDob.setText(jsonObject.getString("birthday"));
        } catch (JSONException e) {

            friendItem.friendName.setText("");
            friendItem.friendDob.setText("");
        }

        listofshit.put(position, friendItem);
        return convertView;
    }

    public int getPositionForSection(int position) {
        return position;
    }

    public int getSectionForPosition(int position) {
        return position;
    }

    public Object[] getSections() {
        return sections;
    }
}

person Liza    schedule 16.01.2013    source источник
comment
Вы хотите это для действия внутри приложения или в качестве автономной функции?   -  person Sahil Mittal    schedule 16.01.2013
comment
@Sahil, я хочу, чтобы пользователь получал напоминание, даже если он/она не использует приложение...   -  person Liza    schedule 16.01.2013


Ответы (1)


Вы можете использовать CRON и API уведомлений facebook.

  1. Сначала вам нужно сохранить в базе данных id и токен расширенного доступа пользователя.
  2. Затем запустите свой планировщик и получите день рождения друзей каждого пользователя, используя токен пользователя.
  3. Отправьте уведомление пользователю с помощью API уведомлений (требуется только токен доступа к приложению, который можно получить по адресу здесь)
person Sahil Mittal    schedule 16.01.2013