Advertisement
Guest User

Invite source code

a guest
Sep 19th, 2019
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. /* Invite Friends */
  2.  
  3. var base64Picture;
  4. var img = new Image();
  5. img.src = 'images/tiledbackground-sheet0.png';
  6. img.onload = function () {
  7. var canvas = document.createElement('canvas'), context = canvas.getContext('2d');
  8. canvas.width = img.width;
  9. canvas.height = img.height;
  10. context.drawImage(img, 0, 0, img.width, img.height);
  11. base64Picture=canvas.toDataURL('images/tiledbackground-sheet0.png');
  12. };
  13.  
  14.  
  15.  
  16. FBInstant.context.chooseAsync().then(function() {
  17. FBInstant.updateAsync({
  18. action: 'CUSTOM',
  19. //cta: 'Join The Fight',
  20. image: base64Picture,
  21. text: 'X just invaded Y\'s village!',
  22. template: 'play_turn',
  23. data: { myReplayData: '...' },
  24. strategy: 'IMMEDIATE',
  25. notification: 'NO_PUSH',
  26. }).then(
  27. () =>{
  28. console.log('updateAsync() success!' + JSON.stringify(data));
  29. FBInstant.quit();
  30. },
  31. error => {
  32. console.error('updateAsync() ERROR! ' + JSON.stringify(error));
  33. }
  34. );
  35.  
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement